From bb8a0c76413c5817cf54fec81e400ab4e8b50491 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 26 Oct 2024 21:01:33 +0100 Subject: [PATCH] Fix: SkipGarbage() skipped all multi-byte utf-8 characters. (#13032) `char` is signed so `str[0] < '0'` applies to all characters higher than 127. --- src/string.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string.cpp b/src/string.cpp index 727fd80681..6d386c04a9 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -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(str[0]) < '0' || IsInsideMM(str[0], ';', '@' + 1) || IsInsideMM(str[0], '[', '`' + 1) || IsInsideMM(str[0], '{', '~' + 1))) str.remove_prefix(1); return str; }