mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-15 16:10:06 +01:00
fix #173, check invalid characters at filenames
This commit is contained in:
parent
324f37ad38
commit
1665de156a
@ -45,7 +45,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.12.20'
|
||||
implementation 'com.simplemobiletools:commons:3.12.21'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||
|
@ -369,13 +369,17 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
mNotes.forEachIndexed { index, note ->
|
||||
val filename = if (extension.isEmpty()) note.title else "${note.title}.$extension"
|
||||
val file = File(parent, filename)
|
||||
exportNoteValueToFile(file.absolutePath, note.value, false) {
|
||||
if (!it) {
|
||||
failCount++
|
||||
}
|
||||
if (!filename.isAValidFilename()) {
|
||||
toast(String.format(getString(R.string.filename_invalid_characters_placeholder, filename)))
|
||||
} else {
|
||||
exportNoteValueToFile(file.absolutePath, note.value, false) {
|
||||
if (!it) {
|
||||
failCount++
|
||||
}
|
||||
|
||||
if (index == mNotes.size - 1) {
|
||||
toast(if (failCount == 0) R.string.exporting_successful else R.string.exporting_some_entries_failed)
|
||||
if (index == mNotes.size - 1) {
|
||||
toast(if (failCount == 0) R.string.exporting_successful else R.string.exporting_some_entries_failed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,15 +44,14 @@ class ExportFileDialog(val activity: SimpleActivity, val note: Note, val callbac
|
||||
}
|
||||
|
||||
val fullFilename = if (extension.isEmpty()) filename else "$filename.$extension"
|
||||
val newFile = File(realPath, fullFilename)
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
if (!fullFilename.isAValidFilename()) {
|
||||
activity.toast(String.format(activity.getString(R.string.filename_invalid_characters_placeholder, fullFilename)))
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
activity.config.lastUsedExtension = extension
|
||||
activity.config.lastUsedSavePath = realPath
|
||||
callback(newFile.absolutePath)
|
||||
callback("$realPath/$fullFilename")
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user