diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-03-03 09:03:45 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-03-03 11:46:42 -0500 |
commit | da0d0009095fb65216165e3ef15c8ea901e94e20 (patch) | |
tree | c3d889e1e2f670f1ec5d207ef1f3413dfd340aee /AK/String.h | |
parent | 434ca784250c129e0acbc2cbc25c1106c5d73060 (diff) | |
download | serenity-da0d0009095fb65216165e3ef15c8ea901e94e20.zip |
AK: Ensure short String instances are valid UTF-8
We are currently only validating long strings.
Diffstat (limited to 'AK/String.h')
-rw-r--r-- | AK/String.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/AK/String.h b/AK/String.h index 45ac7a99fc..32959e26ab 100644 --- a/AK/String.h +++ b/AK/String.h @@ -20,6 +20,7 @@ #include <AK/Traits.h> #include <AK/Types.h> #include <AK/UnicodeUtils.h> +#include <AK/Utf8View.h> #include <AK/Vector.h> namespace AK { @@ -72,6 +73,7 @@ public: static AK_SHORT_STRING_CONSTEVAL String from_utf8_short_string(StringView string) { VERIFY(string.length() <= MAX_SHORT_STRING_BYTE_COUNT); + VERIFY(Utf8View { string }.validate()); ShortString short_string; for (size_t i = 0; i < string.length(); ++i) |