-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: prevent pathname setter from erasing path of path-only URLs
This change prevents the pathname setter from erasing the path of path-only URLs as that would make them cannot-be-a-base URLs. The changes in all files except `src/node_url.cc` have been done by running: ```console git node wpt url ``` Fixes: #39059 Signed-off-by: Darshan Sen <[email protected]> PR-URL: #39060 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Khaidi Chu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
- Loading branch information
1 parent
fdf625b
commit 00cac65
Showing
5 changed files
with
331 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -990,6 +990,26 @@ | |
"hostname": "test", | ||
"port": "12" | ||
} | ||
}, | ||
{ | ||
"comment": "Leading / is not stripped", | ||
"href": "http://example.com/", | ||
"new_value": "///bad.com", | ||
"expected": { | ||
"href": "http://example.com/", | ||
"host": "example.com", | ||
"hostname": "example.com" | ||
} | ||
}, | ||
{ | ||
"comment": "Leading / is not stripped", | ||
"href": "sc://example.com/", | ||
"new_value": "///bad.com", | ||
"expected": { | ||
"href": "sc:///", | ||
"host": "", | ||
"hostname": "" | ||
} | ||
} | ||
], | ||
"hostname": [ | ||
|
@@ -1345,6 +1365,26 @@ | |
"hostname": "", | ||
"pathname": "//p" | ||
} | ||
}, | ||
{ | ||
"comment": "Leading / is not stripped", | ||
"href": "http://example.com/", | ||
"new_value": "///bad.com", | ||
"expected": { | ||
"href": "http://example.com/", | ||
"host": "example.com", | ||
"hostname": "example.com" | ||
} | ||
}, | ||
{ | ||
"comment": "Leading / is not stripped", | ||
"href": "sc://example.com/", | ||
"new_value": "///bad.com", | ||
"expected": { | ||
"href": "sc:///", | ||
"host": "", | ||
"hostname": "" | ||
} | ||
} | ||
], | ||
"port": [ | ||
|
@@ -1571,6 +1611,51 @@ | |
"pathname": "[email protected]" | ||
} | ||
}, | ||
{ | ||
"comment": "Special URLs cannot have their paths erased", | ||
"href": "file:///some/path", | ||
"new_value": "", | ||
"expected": { | ||
"href": "file:///", | ||
"pathname": "/" | ||
} | ||
}, | ||
{ | ||
"comment": "Non-special URLs can have their paths erased", | ||
"href": "foo://somehost/some/path", | ||
"new_value": "", | ||
"expected": { | ||
"href": "foo://somehost", | ||
"pathname": "" | ||
} | ||
}, | ||
{ | ||
"comment": "Non-special URLs with an empty host can have their paths erased", | ||
"href": "foo:///some/path", | ||
"new_value": "", | ||
"expected": { | ||
"href": "foo://", | ||
"pathname": "" | ||
} | ||
}, | ||
{ | ||
"comment": "Path-only URLs cannot have their paths erased", | ||
"href": "foo:/some/path", | ||
"new_value": "", | ||
"expected": { | ||
"href": "foo:/", | ||
"pathname": "/" | ||
} | ||
}, | ||
{ | ||
"comment": "Path-only URLs always have an initial slash", | ||
"href": "foo:/some/path", | ||
"new_value": "test", | ||
"expected": { | ||
"href": "foo:/test", | ||
"pathname": "/test" | ||
} | ||
}, | ||
{ | ||
"href": "unix:/run/foo.socket?timeout=10", | ||
"new_value": "/var/log/../run/bar.socket", | ||
|
@@ -1667,6 +1752,24 @@ | |
"pathname": "/%23" | ||
} | ||
}, | ||
{ | ||
"comment": "? doesn't mess up encoding", | ||
"href": "http://example.net", | ||
"new_value": "/?é", | ||
"expected": { | ||
"href": "http://example.net/%3F%C3%A9", | ||
"pathname": "/%3F%C3%A9" | ||
} | ||
}, | ||
{ | ||
"comment": "# doesn't mess up encoding", | ||
"href": "http://example.net", | ||
"new_value": "/#é", | ||
"expected": { | ||
"href": "http://example.net/%23%C3%A9", | ||
"pathname": "/%23%C3%A9" | ||
} | ||
}, | ||
{ | ||
"comment": "File URLs and (back)slashes", | ||
"href": "file://monkey/", | ||
|
Oops, something went wrong.