Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] parsing comma delimited str with percent encoded comma #336

Merged
merged 1 commit into from Mar 24, 2020

Conversation

@Om4ar
Copy link
Contributor

Om4ar commented Oct 18, 2019

changes on the default decoder to correctly parse comma delimited strings while having percent encoded comma

Fixes #311.

… treated as normal text

Co-authored-by: Mohamed Omar <mohamed.ahmed.c209@gmail.com>
Co-authored-by: Quentin de Longraye <quentin@dldl.fr>
}

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

if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
val = val.split(',');

This comment has been minimized.

Copy link
@ljharb

ljharb Oct 23, 2019

Owner

Removing this is a breaking change; it forces anyone using a custom decoder to add this logic where they previously didn't require it.

This comment has been minimized.

Copy link
@Om4ar

Om4ar Oct 23, 2019

Author Contributor

i agree, i will look into it more to see what can be done

@quentinus95

This comment has been minimized.

Copy link
Contributor

quentinus95 commented Mar 22, 2020

You can pull a non-breaking version here: https://github.com/quentinus95/qs/tree/comma-perecent-parsing

@ljharb ljharb force-pushed the Om4ar:comma-perecent-parsing branch from c45429d to 8aa59b6 Mar 22, 2020
@ljharb

This comment has been minimized.

Copy link
Owner

ljharb commented Mar 22, 2020

@quentinus95 pulled in and rebased, but now the added test is failing.

@quentinus95

This comment has been minimized.

Copy link
Contributor

quentinus95 commented Mar 23, 2020

@ljharb It is due to the rebase.

Can you remove call on line

qs/lib/parse.js

Line 103 in 8aa59b6

val = parseArrayValue(val, options);
?

Thanks

@ljharb

This comment has been minimized.

Copy link
Owner

ljharb commented Mar 24, 2020

@quentinus95 that was added in #359, and is a pretty important bugfix - so this PR may have to be adapted to work with it.

@quentinus95

This comment has been minimized.

Copy link
Contributor

quentinus95 commented Mar 24, 2020

@ljharb thanks, I've just had a look over it, and it would take too long for me to support the fix (especially because #359 has duplicated some of the logic). I've started to do some refactoring but won't have time to achieve it.

If you have some hints on how to fix this without rewriting 20% of the parser, I'll be happy to write the implementation.

@ljharb

This comment has been minimized.

Copy link
Owner

ljharb commented Mar 24, 2020

Looks like just the test needs to be updated.

@ljharb ljharb force-pushed the Om4ar:comma-perecent-parsing branch from 8aa59b6 to cd9a3cd Mar 24, 2020
@ljharb
ljharb approved these changes Mar 24, 2020
@ljharb ljharb merged commit cd9a3cd into ljharb:master Mar 24, 2020
2 checks passed
2 checks passed
Automatic Rebase
Details
Travis CI - Pull Request Build Passed
Details
@@ -429,6 +429,14 @@ test('parse()', function (t) {
st.end();
});

t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) {
st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: ['a', 'b'] });

This comment has been minimized.

Copy link
@quentinus95

quentinus95 Mar 24, 2020

Contributor

@ljharb this test is wrong, it should return "a,b". It's the main point of the pull request and the related issue.

This comment has been minimized.

Copy link
@ljharb

ljharb Mar 25, 2020

Owner

ah, i understand. my bad.

This comment has been minimized.

Copy link
@ljharb

ljharb Mar 25, 2020

Owner

Filed #361 to proceed with a proper fix.

ljharb added a commit that referenced this pull request Mar 25, 2020
Fixes #311. Followup to #336.
ljharb added a commit that referenced this pull request Mar 25, 2020
… treated as normal text (#336)

Co-authored-by: Mohamed Omar <mohamed.ahmed.c209@gmail.com>
Co-authored-by: Quentin de Longraye <quentin@dldl.fr>
ljharb added a commit that referenced this pull request Mar 25, 2020
… treated as normal text (#336)

Co-authored-by: Mohamed Omar <mohamed.ahmed.c209@gmail.com>
Co-authored-by: Quentin de Longraye <quentin@dldl.fr>
ljharb added a commit that referenced this pull request Mar 25, 2020
Fixes #311. Followup to #336.
ljharb added a commit that referenced this pull request Mar 25, 2020
Fixes #311. Followup to #336.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.