diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index fa1c50f419..859df7d714 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -514,7 +514,7 @@ fun selectTxtFileToWrite( @Suppress("DEPRECATION") fun saveFileIntoLegacy(sourceFile: File, dstDirPath: File, outputFilename: String?): File? { // defines another name for the external media - val dstFileName: String + var dstFileName: String // build a filename is not provided if (null == outputFilename) { @@ -529,6 +529,9 @@ fun saveFileIntoLegacy(sourceFile: File, dstDirPath: File, outputFilename: Strin dstFileName = outputFilename } + // remove dangerous characters from the filename + dstFileName = dstFileName.replace(Regex("""[/\\]"""), "_") + var dstFile = File(dstDirPath, dstFileName) // if the file already exists, append a marker