Skip to content

Commit ca55d0f

Browse files
committed
[Fix] parse: avoid a crash with interpretNumericEntities: true, comma: true, and iso charset
1 parent 99fd543 commit ca55d0f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var parseValues = function parseQueryStringValues(str, options) {
101101
}
102102

103103
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
104-
val = interpretNumericEntities(val);
104+
val = interpretNumericEntities(String(val));
105105
}
106106

107107
if (part.indexOf('[]=') > -1) {

test/parse.js

+9
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,15 @@ test('parse()', function (t) {
998998
st.end();
999999
});
10001000

1001+
t.test('interpretNumericEntities with comma:true and iso charset does not crash', function (st) {
1002+
st.deepEqual(
1003+
qs.parse('b&a[]=1,' + urlEncodedNumSmiley, { comma: true, charset: 'iso-8859-1', interpretNumericEntities: true }),
1004+
{ b: '', a: ['1,☺'] }
1005+
);
1006+
1007+
st.end();
1008+
});
1009+
10011010
t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) {
10021011
st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' });
10031012
st.end();

0 commit comments

Comments
 (0)