Skip to content

Commit

Permalink
Resolves servo#844 by returning Ok(()) if username or password is e…
Browse files Browse the repository at this point in the history
…mpty
  • Loading branch information
chanced committed Jul 2, 2023
1 parent a3e07c7 commit 7859b69
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions url/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,9 @@ impl Url {
pub fn set_password(&mut self, password: Option<&str>) -> Result<(), ()> {
// has_host implies !cannot_be_a_base
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
if password.is_none() || password == Some("") {
return Ok(());
}
return Err(());
}
let password = password.unwrap_or_default();
Expand Down Expand Up @@ -2182,6 +2185,9 @@ impl Url {
pub fn set_username(&mut self, username: &str) -> Result<(), ()> {
// has_host implies !cannot_be_a_base
if !self.has_host() || self.host() == Some(Host::Domain("")) || self.scheme() == "file" {
if username.is_empty() {
return Ok(());
}
return Err(());
}
let username_start = self.scheme_end + 3;
Expand Down

0 comments on commit 7859b69

Please sign in to comment.