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

url, querystring: web platform tests broken by WHATWG URL implementation #11093

Closed
joyeecheung opened this issue Feb 1, 2017 · 8 comments
Closed
Labels
querystring Issues and PRs related to the built-in querystring module. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Comments

@joyeecheung
Copy link
Member

joyeecheung commented Feb 1, 2017

Version: 90c2ac7

Broken tests discovered in #11079 that don't have tracking issues:

Leading ??

In upstream urltestdata.json:

  {
    "input": "??a=b&c=d",
    "base": "http://example.org/foo/bar",
    "href": "http://example.org/foo/bar??a=b&c=d",
    "origin": "http://example.org",
    "protocol": "http:",
    "username": "",
    "password": "",
    "host": "example.org",
    "hostname": "example.org",
    "port": "",
    "pathname": "/foo/bar",
    "search": "??a=b&c=d",
    "searchParams": "%3Fa=b&c=d",
    "hash": ""
  }

Expected searchParams.toString() to be %3Fa=b&c=d, got a=b&c=d(the second ? is ignored).

Also presents in upstream url-constructor.html

var url2 = bURL('http://example.org/file??a=b&c=d')
assert_equals(url2.search, '??a=b&c=d')
assert_equals(url2.searchParams.toString(), '%3Fa=b&c=d')

url2.href = 'http://example.org/file??a=b'
assert_equals(url2.search, '??a=b')
assert_equals(url2.searchParams.toString(), '%3Fa=b')

Note: this only appears when we parse through URL

new URL('http://example.org/file??a=b&c=d').searchParams.toString()
// 'a=b&c=d'
new URLSearchParams('??a=b&c=d').toString()
// '%3Fa=b&c=d'

Space should be escaped as +

In upstream url-constructor.html

searchParams.append('i', ' j ')
assert_equals(url.search, '?e=f&g=h&i=+j+')
assert_equals(url.searchParams.toString(), 'e=f&g=h&i=+j+')
assert_equals(searchParams.get('i'), ' j ')

In urlsearchparams-stringifier.html

var params = new URLSearchParams();
params.append('a', 'b c');
assert_equals(params + '', 'a=b+c');
params.delete('a');
params.append('a b', 'c');
assert_equals(params + '', 'a+b=c');

Currently it's escaped as %20 by the querystring module. I suspect fixing this in querystring might be too breaking though.

@joyeecheung joyeecheung added whatwg-url Issues and PRs related to the WHATWG URL implementation. querystring Issues and PRs related to the built-in querystring module. labels Feb 1, 2017
@mscdex
Copy link
Contributor

mscdex commented Feb 1, 2017

I'm starting to wonder if the whatwg url implementation should just have its own querystring implementation ...

@joyeecheung
Copy link
Member Author

Yeah I agree, when it is the spec behavior that is breaking(and breaking big), it's impossible to make a choice. I remember @TimothyGu mentioned he had implemented another one in C++?

@TimothyGu
Copy link
Member

I'm starting to wonder if the whatwg url implementation should just have its own querystring implementation

That was what I was pushing for. See #10967 (comment) and #10821.

@jasnell
Copy link
Member

jasnell commented Feb 1, 2017

Yes, my intent all along was to have a separate parsing algorithm for querystring but just hadn't managed to get to it.

@joyeecheung joyeecheung changed the title url, querystring: escaping searchParams per WHATWG URL spec url, querystring: web platform tests broken by WHATWG URL implementation Feb 2, 2017
TimothyGu added a commit to TimothyGu/node that referenced this issue Feb 14, 2017
@TimothyGu
Copy link
Member

Actually, reopening this since only first issue of leading ?? is fixed with fa41dd1.

@joyeecheung
Copy link
Member Author

We can probably close this in favor of #10821?

@TimothyGu
Copy link
Member

@joyeecheung, I'd be ok with that

@TimothyGu
Copy link
Member

Closed in favor of #10821.

italoacasas pushed a commit to italoacasas/node that referenced this issue Feb 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
querystring Issues and PRs related to the built-in querystring module. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

No branches or pull requests

4 participants