Skip to content

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

Description

@joyeecheung

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.

Activity

  1. added
    whatwg-urlIssues and PRs related to the WHATWG URL implementation.
    querystringIssues and PRs related to the built-in querystring module.
    on Feb 1, 2017
  2. mscdex commented on Feb 1, 2017

    @mscdex
    Contributor

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

  3. joyeecheung commented on Feb 1, 2017

    @joyeecheung
    MemberAuthor

    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++?

  4. TimothyGu commented on Feb 1, 2017

    @TimothyGu
    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.

  5. jasnell commented on Feb 1, 2017

    @jasnell
    Member

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

  6. changed the title [-]url, querystring: escaping searchParams per WHATWG URL spec[/-] [+]url, querystring: web platform tests broken by WHATWG URL implementation[/+] on Feb 2, 2017
  7. TimothyGu commented on Feb 17, 2017

    @TimothyGu
    Member

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

  8. joyeecheung commented on Feb 17, 2017

    @joyeecheung
    MemberAuthor

    We can probably close this in favor of #10821?

  9. TimothyGu commented on Feb 17, 2017

    @TimothyGu
    Member

    @joyeecheung, I'd be ok with that

  10. TimothyGu commented on Feb 21, 2017

    @TimothyGu
    Member

    Closed in favor of #10821.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    querystringIssues and PRs related to the built-in querystring module.whatwg-urlIssues and PRs related to the WHATWG URL implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions