Fix: SkipGarbage() skipped all multi-byte utf-8 characters. (#13032)

`char` is signed so `str[0] < '0'` applies to all characters higher than 127.
This commit is contained in:
Peter Nelson 2024-10-26 21:01:33 +01:00 committed by GitHub
parent 1191efa581
commit bb8a0c7641
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -551,7 +551,7 @@ char *strcasestr(const char *haystack, const char *needle)
*/
static std::string_view SkipGarbage(std::string_view str)
{
while (!str.empty() && (str[0] < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1);
while (!str.empty() && (static_cast<uint8_t>(str[0]) < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1);
return str;
}