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

Failure parsing url escaped data from windows #43

Closed
dspaeth-faber opened this issue Sep 29, 2014 · 4 comments
Closed

Failure parsing url escaped data from windows #43

dspaeth-faber opened this issue Sep 29, 2014 · 4 comments
Assignees

Comments

@dspaeth-faber
Copy link

Hi,

a windows client sends me the following sequence:

%f6%e4%fc%e1%20

Javascripts unescape can handle this sequence,
Qs can't. I think it's ucs2 encoding.

A spec would look like this:

qs = require('qs')

describe 'Qs', ->

  describe '#parse', ->
    it 'parses ucs2 from windows', (done) ->
      expect(unescape('%f6%e4%fc%e1%20')).to.be.like('öäüá ')
      expect(qs.parse('a=%f6%e4%fc%e1%20')).to.be.like( {'a': 'öäüá '})
      done()

Is this to be considered a Qs-Bug?

Regards
Dieter

@nlf
Copy link
Collaborator

nlf commented Sep 29, 2014

In my opinion, no.

Qs only performs URI encoding/decoding (with encodeURIComponent and decodeURIComponent). Since that string is not URI encoded, it's not expected that Qs would parse it.

@nlf nlf added the question label Sep 29, 2014
@nlf nlf self-assigned this Sep 29, 2014
@nlf nlf added non-issue and removed question labels Sep 29, 2014
@nlf nlf closed this as completed Sep 29, 2014
@dspaeth-faber
Copy link
Author

@nlf why isn't it uri encoded? The hole url would look like this http://www.example.com?a=%f6%e4%fc%e1%20 What's wrong with this uri? http://www.motobit.com/util/url-decoder.asp decodes this uri as
windows-1250, iso-8859-1, utf-7 => http://www.example.com?a=öäüá

RFC says nothing about needed encoding.

@nlf
Copy link
Collaborator

nlf commented Sep 30, 2014

Well using node's encodeURIComponent you get

encodeURIComponent('öäüá ')
'%C3%B6%C3%A4%C3%BC%C3%A1%20'

Which is definitely not encoded the same as your sample, this is because the encodeURIComponent and decodeURIComponent methods adhere to RFC 3629 and uses UTF-8 encoding since RFC 3986 does not specify how to encode non-ascii values.

@dspaeth-faber
Copy link
Author

Ok, so Qs only supports the same encoding as encodeURIComponent supports. Exotic clients like windows clients are not supported. Thank you for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants