Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit a839978

Browse files
committed
also escape leading ascii letters
1 parent 979649b commit a839978

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec.emu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ contributors:
3131
1. Let _escaped_ be the empty String.
3232
1. Let _cpList_ be StringToCodePoints(_S_).
3333
1. For each code point _c_ in _cpList_, do
34-
1. If _escaped_ is the empty String and _c_ is matched by |DecimalDigit|, then
35-
1. NOTE: Escaping a leading digit ensures that output corresponds with pattern text which may be used after a `\0` character escape or a |DecimalEscape| such as `\1` and still match _S_ rather than be interpreted as an extension of the preceding escape sequence.
36-
1. Set _escaped_ to the string-concatenation of _escaped_, the code unit 0x005C (REVERSE SOLIDUS), *"x3"*, and the code unit whose numeric value is the numeric value of _c_.
34+
1. If _escaped_ is the empty String, and _c_ is matched by |DecimalDigit| or |AsciiLetter|, then
35+
1. NOTE: Escaping a leading digit ensures that output corresponds with pattern text which may be used after a `\0` character escape or a |DecimalEscape| such as `\1` and still match _S_ rather than be interpreted as an extension of the preceding escape sequence. Escaping a leading ASCII letter does the same for the context after `\c`.
36+
1. Let _hex_ be Number::toString(𝔽(_c_), 16).
37+
1. Assert: The length of _hex_ is 2.
38+
1. Set _escaped_ to the string-concatenation of the code unit 0x005C (REVERSE SOLIDUS), *"x"*, _hex_.
3739
1. Else,
3840
1. Set _escaped_ to the string-concatenation of _escaped_ and EncodeForRegExpEscape(_c_).
3941
1. Return _escaped_.

0 commit comments

Comments
 (0)