LibWeb: Implement USVString scalar value handling

USVString is defined in the IDL spec as:

> The USVString type corresponds to scalar value strings. Depending on
> the context, these can be treated as sequences of either 16-bit
> unsigned integer code units or scalar values.

This means we need to account for surrogate code points by using the
replacement character.

This fixes the last test in https://wpt.live/url/url-constructor.any.html
This commit is contained in:
Shannon Booth 2024-08-07 18:42:14 +12:00 committed by Tim Ledbetter
commit aa32bfa448
Notes: github-actions[bot] 2024-08-08 09:50:59 +00:00
3 changed files with 32 additions and 4 deletions

View file

@ -163,6 +163,17 @@ pathname => '/foo/bar'
search => '??a=b&c=d'
searchParams => '%3Fa=b&c=d'
hash => ''
new URL('http://example.com/<2F><><EFBFBD>𐟾<EFBFBD><F0909FBE><EFBFBD>﷐﷏﷯ﷰ￾￿?<3F><><EFBFBD>𐟾<EFBFBD><F0909FBE><EFBFBD>﷐﷏﷯ﷰ￾￿', undefined)
protocol => 'http:'
username => ''
password => ''
host => 'example.com'
hostname => 'example.com'
port => ''
pathname => '/%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF'
search => '?%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF'
searchParams => '%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF='
hash => ''
=========================================
URL.parse('ftp://serenityos.org:21', undefined)
protocol => 'ftp:'
@ -329,3 +340,14 @@ pathname => '/foo/bar'
search => '??a=b&c=d'
searchParams => '%3Fa=b&c=d'
hash => ''
URL.parse('http://example.com/<2F><><EFBFBD>𐟾<EFBFBD><F0909FBE><EFBFBD>﷐﷏﷯ﷰ￾￿?<3F><><EFBFBD>𐟾<EFBFBD><F0909FBE><EFBFBD>﷐﷏﷯ﷰ￾￿', undefined)
protocol => 'http:'
username => ''
password => ''
host => 'example.com'
hostname => 'example.com'
port => ''
pathname => '/%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF'
search => '?%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF'
searchParams => '%EF%BF%BD%F0%90%9F%BE%EF%BF%BD%EF%B7%90%EF%B7%8F%EF%B7%AF%EF%B7%B0%EF%BF%BE%EF%BF%BF='
hash => ''