LibURL: Allow inputs containing only whitespace

The check for:

```
    if (start_index >= end_index)
        return {};
```

To prevent an out of bounds when trimming the start and end of the input
of whitespace was preventing valid URLs (only having whitespace in the
input) from being parsed.

Instead, prevent start_index from ever getting above end_index in the
first place, and don't treat empty inputs as an error.

Fixes one WPT test on:

https://wpt.live/url/url-constructor.any.html
This commit is contained in:
Shannon Booth 2024-08-06 02:00:52 +12:00 committed by Tim Ledbetter
commit d6af5bf5eb
Notes: github-actions[bot] 2024-08-05 16:22:19 +00:00
3 changed files with 30 additions and 16 deletions

View file

@ -108,6 +108,16 @@ port => '9000'
pathname => '/path'
search => '?query'
hash => '#frag'
new URL(' \t', 'http://ladybird.org/foo/bar')
protocol => 'http:'
username => ''
password => ''
host => 'ladybird.org'
hostname => 'ladybird.org'
port => ''
pathname => '/foo/bar'
search => ''
hash => ''
=========================================
URL.parse('ftp://serenityos.org:21', undefined)
protocol => 'ftp:'
@ -219,3 +229,13 @@ port => '9000'
pathname => '/path'
search => '?query'
hash => '#frag'
URL.parse(' \t', 'http://ladybird.org/foo/bar')
protocol => 'http:'
username => ''
password => ''
host => 'ladybird.org'
hostname => 'ladybird.org'
port => ''
pathname => '/foo/bar'
search => ''
hash => ''