fix: check suffix characters
This commit is contained in:
1 parent
d5c79c78a1
commit
aeb14c62ec
1 file changed
+3
-1
@@ -144,7 +144,9 @@ object BookHelp {
|
||||
|
||||
fun getImageSuffix(src: String): String {
|
||||
var suffix = src.substringAfterLast(".").substringBefore(",")
|
||||
if (suffix.length > 5) {
|
||||
//检查截取的后缀字符是否合法 [a-zA-Z0-9]
|
||||
val fileSuffixRegex = Regex("^[a-z0-9]+$", RegexOption.IGNORE_CASE)
|
||||
if (suffix.length > 5 || !suffix.matches(fileSuffixRegex)) {
|
||||
suffix = "jpg"
|
||||
}
|
||||
return suffix
|
||||
|
||||
Reference in new issue
Block a user