Skip to content

Commit

Permalink
Fix escaping in RegExp.prototype.source (#3619)
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad authored Jan 27, 2024
1 parent 6be4296 commit 8a1383a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/engine/src/builtins/regexp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,10 @@ impl RegExp {
for c in src.code_points() {
match c {
CodePoint::Unicode('/') => s.extend_from_slice(utf16!(r"\/")),
CodePoint::Unicode('\n') => s.extend_from_slice(utf16!(r"\\n")),
CodePoint::Unicode('\r') => s.extend_from_slice(utf16!(r"\\r")),
CodePoint::Unicode('\n') => s.extend_from_slice(utf16!(r"\n")),
CodePoint::Unicode('\r') => s.extend_from_slice(utf16!(r"\r")),
CodePoint::Unicode('\u{2028}') => s.extend_from_slice(utf16!(r"\u2028")),
CodePoint::Unicode('\u{2029}') => s.extend_from_slice(utf16!(r"\u2029")),
CodePoint::Unicode(c) => s.extend_from_slice(c.encode_utf16(&mut buf)),
CodePoint::UnpairedSurrogate(surr) => s.push(surr),
}
Expand Down

0 comments on commit 8a1383a

Please sign in to comment.