Skip to content

Commit 17f77a0

Browse files
committed
fix: throw error on invalid length
1 parent db09d86 commit 17f77a0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/internals/querystring.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ function encodeString(str) {
7171
// Surrogate pair
7272
++i;
7373

74+
// This branch should never happen because all URLSearchParams entries
75+
// should already be converted to USVString. But, included for
76+
// completion's sake anyway.
77+
if (i >= len) {
78+
throw new Error("URI malformed");
79+
}
80+
7481
const c2 = str.charCodeAt(i) & 0x3FF;
7582

7683
lastPos = i + 1;

0 commit comments

Comments
 (0)