Skip to content

Commit 1bf5d1a

Browse files
watilderichardlau
authored andcommitted
querystring: manage percent character at unescape
Related: #33892 Fixes: #35012 PR-URL: #35013 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Shingo Inoue <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 1be6956 commit 1bf5d1a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/querystring.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ function unescapeBuffer(s, decodeSpaces) {
9494
hexHigh = unhexTable[currentChar];
9595
if (!(hexHigh >= 0)) {
9696
out[outIndex++] = 37; // '%'
97+
continue;
9798
} else {
9899
nextChar = s.charCodeAt(++index);
99100
hexLow = unhexTable[nextChar];
100101
if (!(hexLow >= 0)) {
101102
out[outIndex++] = 37; // '%'
102-
out[outIndex++] = currentChar;
103-
currentChar = nextChar;
103+
index--;
104104
} else {
105105
hasHex = true;
106106
currentChar = hexHigh * 16 + hexLow;

test/parallel/test-querystring.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ const qsUnescapeTestCases = [
175175
['there%2Qare%0-fake%escaped values in%%%%this%9Hstring',
176176
'there%2Qare%0-fake%escaped values in%%%%this%9Hstring'],
177177
['%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37',
178-
' !"#$%&\'()*+,-./01234567']
178+
' !"#$%&\'()*+,-./01234567'],
179+
['%%2a', '%*'],
180+
['%2sf%2a', '%2sf*'],
181+
['%2%2af%2a', '%2*f*']
179182
];
180183

181184
assert.strictEqual(qs.parse('id=918854443121279438895193').id,

0 commit comments

Comments
 (0)