Skip to content

Commit 7859b69

Browse files
committed
Resolves servo#844 by returning Ok(()) if username or password is empty
1 parent a3e07c7 commit 7859b69

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

url/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,9 @@ impl Url {
20882088
pub fn set_password(&mut self, password: Option<&str>) -> Result<(), ()> {
20892089
// has_host implies !cannot_be_a_base
20902090
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
2091+
if password.is_none() || password == Some("") {
2092+
return Ok(());
2093+
}
20912094
return Err(());
20922095
}
20932096
let password = password.unwrap_or_default();
@@ -2182,6 +2185,9 @@ impl Url {
21822185
pub fn set_username(&mut self, username: &str) -> Result<(), ()> {
21832186
// has_host implies !cannot_be_a_base
21842187
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
2188+
if username.is_empty() {
2189+
return Ok(());
2190+
}
21852191
return Err(());
21862192
}
21872193
let username_start = self.scheme_end + 3;

0 commit comments

Comments
 (0)