[whatwg/url] Should parsing take into account state override on port overflow (Issue #831)

### What is the issue with the URL Standard?

WPT has the following test:

https://github.com/web-platform-tests/wpt/blob/15726bae77bdf1b5fc55143589d09ab180b89218/url/resources/setters_tests.json#L983

```json
        {
            "comment": "Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though.",
            "href": "http://example.net/path",
            "new_value": "example.com:65536",
            "expected": {
                "href": "http://example.com/path",
                "host": "example.com",
                "hostname": "example.com",
                "port": ""
            }
        },
```

The host [setter steps](https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-host) are to "Basic URL parse the given value, with url as url and host state as state override.".

This results in the URL parsing of:

```
Parsing 'example.com:65536'
Host state with code point U+0065 (e).
Host state with code point U+0078 (x).
Host state with code point U+0061 (a).
Host state with code point U+006D (m).
Host state with code point U+0070 (p).
Host state with code point U+006C (l).
Host state with code point U+0065 (e).
Host state with code point U+002E (.).
Host state with code point U+0063 (c).
Host state with code point U+006F (o).
Host state with code point U+006D (m).
Host state with code point U+003A (:).
Port state with code point U+0036 (6).
Port state with code point U+0035 (5).
Port state with code point U+0035 (5).
Port state with code point U+0033 (3).
Port state with code point U+0036 (6).
Port state with EOF.
```

But the [port ](https://url.spec.whatwg.org/#port-state) state will return in URL parsing failure due to:

>  If port is greater than 216 − 1, port-out-of-range validation error, return failure.

Which, if I am understanding correctly, should mean that the host setter steps should not result in the href being changed.

On a port overflow (if state override is given) - should the spec be doing:

> If state override is given, then return.

Or is this a misunderstanding on my part of the spec?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/831
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/831@github.com>

Received on Monday, 12 August 2024 13:09:45 UTC