summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-07-18 05:15:10 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-18 21:10:55 +0430
commitc85ab623c055aef73185400a5ba9006c8f8a87d5 (patch)
tree3fe65a0a4328ca2ead65d71429f2b7035dfe18ea /Userland/Libraries/LibJS/Runtime
parentf364fcec5da902ca8ae84dc0bca0f23533cebaa4 (diff)
downloadserenity-c85ab623c055aef73185400a5ba9006c8f8a87d5.zip
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 5881153ce9..c3c18e9251 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -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;