Skip to content

Commit d8ce238

Browse files
authored
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 <[email protected]>
1 parent 1dbaeaa commit d8ce238

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/ModuleViewModel.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ class ModuleViewModel : ViewModel() {
129129
}
130130
}
131131

132+
private fun sanitizeVersionString(version: String): String {
133+
return version.replace(Regex("[^a-zA-Z0-9.\\-_]"), "_")
134+
}
135+
132136
fun checkUpdate(m: ModuleInfo): Triple<String, String, String> {
133137
val empty = Triple("", "", "")
134138
if (m.updateJson.isEmpty() || m.remove || m.update || !m.enabled) {
@@ -158,7 +162,8 @@ class ModuleViewModel : ViewModel() {
158162
JSONObject(result)
159163
}.getOrNull() ?: return empty
160164

161-
val version = updateJson.optString("version", "")
165+
var version = updateJson.optString("version", "")
166+
version = sanitizeVersionString(version)
162167
val versionCode = updateJson.optInt("versionCode", 0)
163168
val zipUrl = updateJson.optString("zipUrl", "")
164169
val changelog = updateJson.optString("changelog", "")
@@ -168,4 +173,4 @@ class ModuleViewModel : ViewModel() {
168173

169174
return Triple(zipUrl, version, changelog)
170175
}
171-
}
176+
}

0 commit comments

Comments
 (0)