mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 04:08:44 +03:00
Replace dangerous characters in the filename with underscores
This commit is contained in:
parent
0f22dc610d
commit
d75b7434cf
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue