Skip to content

Commit

Permalink
[Fix] parse: avoid a crash with interpretNumericEntities: true, com…
Browse files Browse the repository at this point in the history
…ma: true, and iso charset
  • Loading branch information
ljharb committed Aug 8, 2024
1 parent 99fd543 commit ca55d0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var parseValues = function parseQueryStringValues(str, options) {
}

if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
val = interpretNumericEntities(String(val));
}

if (part.indexOf('[]=') > -1) {
Expand Down
9 changes: 9 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,15 @@ test('parse()', function (t) {
st.end();
});

t.test('interpretNumericEntities with comma:true and iso charset does not crash', function (st) {
st.deepEqual(
qs.parse('b&a[]=1,' + urlEncodedNumSmiley, { comma: true, charset: 'iso-8859-1', interpretNumericEntities: true }),
{ b: '', a: ['1,☺'] }
);

st.end();
});

t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) {
st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' });
st.end();
Expand Down

0 comments on commit ca55d0f

Please sign in to comment.