refactor(metadata): Simplify code

This commit is contained in:
Ahmad Ansori Palembani 2024-11-20 20:12:33 +07:00
parent a2d6ac2a8b
commit fbe2d8c701
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 10 additions and 9 deletions

View file

@ -29,7 +29,7 @@ The format is simplified version of [Keep a Changelog](https://keepachangelog.co
- Fixed reader sometimes won't load images - Fixed reader sometimes won't load images
- Handle some uncaught crashes - Handle some uncaught crashes
- Fixed crashes due to GestureDetector's firstEvent is sometimes null on some devices - Fixed crashes due to GestureDetector's firstEvent is sometimes null on some devices
- Fixed download failed caused by invalid XML 1.0 character - Fixed download failed due to invalid XML 1.0 character
- Fixed issues with shizuku in a multi user setup (@Redjard) - Fixed issues with shizuku in a multi user setup (@Redjard)
### Other ### Other

View file

@ -234,12 +234,13 @@ enum class ComicInfoPublishingStatus(
} }
// REF: https://www.w3.org/TR/xml/#charsets // REF: https://www.w3.org/TR/xml/#charsets
fun String.stripNonValidXML1_0Characters(): String { fun String.stripNonValidXML1_0Characters() = filter { it.isValidXML1_0() }
return this.filter {
val c = it.code fun Char.isValidXML1_0() = code.let { c ->
c == 0x9 || c == 0xA || c == 0xD || c == 0x9 ||
((c >= 0x20) && (c <= 0xD7FF)) || c == 0xA ||
((c >= 0xE000) && (c <= 0xFFFD)) || c == 0xD ||
((c >= 0x10000) && (c <= 0x10FFFF)) c in 0x20..0xD7FF ||
} c in 0xE000..0xFFFD ||
c in 0x10000..0x10FFFF
} }