Add a formatting string for the update list #2556 (#2597)

Fix module update failures caused by spaces and other non Linux readable
characters


Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-05-20 16:10:12 +08:00
committed by GitHub
parent 1dbaeaaae6
commit d8ce238c37

View File

@@ -129,6 +129,10 @@ class ModuleViewModel : ViewModel() {
}
}
private fun sanitizeVersionString(version: String): String {
return version.replace(Regex("[^a-zA-Z0-9.\\-_]"), "_")
}
fun checkUpdate(m: ModuleInfo): Triple<String, String, String> {
val empty = Triple("", "", "")
if (m.updateJson.isEmpty() || m.remove || m.update || !m.enabled) {
@@ -158,7 +162,8 @@ class ModuleViewModel : ViewModel() {
JSONObject(result)
}.getOrNull() ?: return empty
val version = updateJson.optString("version", "")
var version = updateJson.optString("version", "")
version = sanitizeVersionString(version)
val versionCode = updateJson.optInt("versionCode", 0)
val zipUrl = updateJson.optString("zipUrl", "")
val changelog = updateJson.optString("changelog", "")