|
|
@@ -10,6 +10,7 @@ import kotlinx.coroutines.Dispatchers.IO
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
|
import splitties.init.appCtx
|
|
|
+import java.util.regex.Matcher
|
|
|
import kotlin.coroutines.resume
|
|
|
import kotlin.coroutines.resumeWithException
|
|
|
|
|
|
@@ -36,7 +37,8 @@ fun CharSequence.replace(regex: Regex, replacement: String, timeout: Long): Stri
|
|
|
bindings["result"] = matcher.group()
|
|
|
eval(replacement1, bindings)
|
|
|
}.toString()
|
|
|
- matcher.appendReplacement(stringBuffer, jsResult)
|
|
|
+ val quotedResult = Matcher.quoteReplacement(jsResult)
|
|
|
+ matcher.appendReplacement(stringBuffer, quotedResult)
|
|
|
} else {
|
|
|
matcher.appendReplacement(stringBuffer, replacement1)
|
|
|
}
|
|
|
@@ -49,7 +51,8 @@ fun CharSequence.replace(regex: Regex, replacement: String, timeout: Long): Stri
|
|
|
}
|
|
|
handler.postDelayed(timeout) {
|
|
|
if (coroutine.isActive) {
|
|
|
- val timeoutMsg = "替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:${this}"
|
|
|
+ val timeoutMsg =
|
|
|
+ "替换超时,3秒后还未结束将重启应用\n替换规则$regex\n替换内容:$charSequence"
|
|
|
val exception = RegexTimeoutException(timeoutMsg)
|
|
|
block.cancel(exception)
|
|
|
appCtx.longToastOnUi(timeoutMsg)
|