[whatwg/url] What happens on non-scalar strings? (Issue #897)

ChALkeR created an issue (whatwg/url#897)

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

E.g. [username setter](https://url.spec.whatwg.org/#dom-url-username) calls [set the username](https://url.spec.whatwg.org/#set-the-username) on value as-is, which links to [UTF-8 percent-encode](https://url.spec.whatwg.org/#string-utf-8-percent-encode), which is defined only on scalar-value strings

In all major browsers, input is converted to a well-formed string by replacing lone surrogates with `U+FFFD`

In utf8 context:
```js
x = new URL('https://example.com'); x.username = '\ud800'; x.username
'%EF%BF%BD'
a = document.createElement("a"); a.href = 'https://example.com/?\ud800'; a.search.substr(1)
'%EF%BF%BD'
```

In `iso-2022-jp` context:
```js
a = document.createElement("a"); a.href = 'https://example.com/?\ud800'; a.search.substr(1)
'%26%2365533%3B'
```

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

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

Received on Saturday, 24 January 2026 10:57:17 UTC