Commit b769d28
querystring: validate surrogate pairs in encodeStr
The surrogate pair path in `encodeStr` only checked that a second code
unit existed; it did not verify that the leading unit was a high
surrogate (0xD800-0xDBFF) or that the trailing unit was a low surrogate
(0xDC00-0xDFFF). A lone high surrogate followed by a non-surrogate (or
a lone low surrogate) was silently combined and emitted as a
syntactically valid four-byte UTF-8 sequence representing an entirely
different code point, producing malformed output that does not
roundtrip through `querystring.parse`.
Match `encodeURIComponent` semantics by throwing `ERR_INVALID_URI` when
either half of the pair is not a valid surrogate.
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: DeepView Autofix <[email protected]>
Co-Authored-By: Nikita Skovoroda <[email protected]>
Signed-off-by: Nikita Skovoroda <[email protected]>1 parent 14e16db commit b769d28
2 files changed
Lines changed: 24 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | | - | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
| |||
0 commit comments