Closed
Bug 1874117
Opened 2 years ago
Closed 1 years ago
Non-special URLs can have their paths erased
Categories
(Core :: Networking, defect, P3)
Core
Networking
Tracking
()
RESOLVED
FIXED
People
(Reporter: valentin, Assigned: dotoole)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged])
This bug is coming via rust-url
pub extern "C" fn mozurl_set_pathname(url: &mut MozURL, path: &nsACString) -> nsresult {
debug_assert_mut!(url);
let path = try_or_malformed!(str::from_utf8(path));
quirks::set_pathname(url, path);
But the implementation https://github.com/servo/rust-url/blob/f447500049cbfe42203ff16026842e74f3fd99ac/url/src/quirks.rs#L272-L287
pub fn set_pathname(url: &mut Url, new_pathname: &str) {
if url.cannot_be_a_base() {
return;
}
if new_pathname.starts_with('/')
|| (SchemeType::from(url.scheme()).is_special()
// \ is a segment delimiter for 'special' URLs"
&& new_pathname.starts_with('\\'))
{
url.set_path(new_pathname)
} else {
let mut path_to_set = String::from("/");
path_to_set.push_str(new_pathname);
url.set_path(&path_to_set)
}
}
The problem is that for a non-special url it will set the pathname to /
Reporter | ||
Comment 1•2 years ago
|
||
The test that is failing is Setting <foo://somehost/some/path>.pathname = '' Non-special URLs can have their paths erased
Gets foo://somehost/
instead of foo://somehost
Reporter | ||
Comment 2•2 years ago
|
||
If the URL is not special, and the new_pathname is empty, then we don't need to prepend a / when calling set_path.
Blocks: interop-2024-url
Status: NEW → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•