Skip to content

Commit

Permalink
Merge pull request #209 from chenxiaolong/replacement
Browse files Browse the repository at this point in the history
FilenameTemplate: Fix potential crash when a variable's value contains `\` or `$`
  • Loading branch information
chenxiaolong authored Dec 27, 2022
2 parents 30d7621 + ad39ee0 commit e92260c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/chiller3/bcr/FilenameTemplate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.util.Log
import androidx.documentfile.provider.DocumentFile
import java.util.*
import java.util.regex.Matcher
import java.util.regex.Pattern

class FilenameTemplate private constructor(props: Properties) {
Expand Down Expand Up @@ -77,7 +78,7 @@ class FilenameTemplate private constructor(props: Properties) {
val name = m.group(1)!!
val replacement = getVar(index, name)

m.appendReplacement(this, replacement ?: "")
m.appendReplacement(this, Matcher.quoteReplacement(replacement ?: ""))

++index
}
Expand Down

0 comments on commit e92260c

Please sign in to comment.