[whatwg/url] Percent-encoding of query wrong for ISO-2022-JP (#557)

If you look at the number of state transitions (hint: count `%1B` instances) in the example below you can see that invoking the encoder code-point-by-code-point does not match implementations.
```js
 function encode(input, output, desc) {
   test(function() {
     var a = document.createElement("a") // <a> uses document encoding for URL's query
     a.href = "https://example.com/?" + input
     assert_equals(a.search.substr(1), output) // remove leading "?"
   }, "iso-2022-jp encoder: " + desc)
 }

 encode("\uFF90\u4F69", "%1B$B%_PP%1B(B");
 encode("\uFF90a\u4F69", "%1B$B%_%1B(Ba%1B$BPP%1B(B");
```
There might be a related thing here, discovered in https://github.com/web-platform-tests/wpt/pull/26158 by @JKingweb, that implementations skip invoking encoders if the input is entirely in the ASCII range. (Again, something that uniquely applies to ISO-2022-JP. Form submission should be checked here as well before deciding on something.)

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

Received on Monday, 19 October 2020 09:16:47 UTC