1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:37:34 +00:00

LibJS: Use a Utf8View on the subject if the regex has the unicode flag

This makes LibRegex behave (more) correctly with regards to matching
unicode code points.
This commit is contained in:
Ali Mohammad Pur 2021-07-18 05:15:10 +04:30 committed by Ali Mohammad Pur
parent f364fcec5d
commit c85ab623c0

View file

@ -240,7 +240,12 @@ static Value regexp_builtin_exec(GlobalObject& global_object, RegExpObject& rege
}
regex.start_offset = last_index;
result = regex.match(string);
// FIXME: JavaScript strings are UTF-16, update this if the backing storage
// encoding changes for spec compliance reasons.
if (unicode)
result = regex.match(Utf8View { string });
else
result = regex.match(string);
if (result.success)
break;