mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
AK: Ensure short String instances are valid UTF-8
We are currently only validating long strings.
This commit is contained in:
parent
434ca78425
commit
da0d000909
3 changed files with 37 additions and 15 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue