Skip to content

URL with empty password is parsed as None #793

Open
@nemosupremo

Description

@nemosupremo

Trying to parse a URL with an empty password will (incorrectly?) have password be set to None. However if you set password to Some(""), then call url.to_string(), then the password separator in the url will be set. parse and to_string will fail to round trip in this edge case.

let mut url = match reqwest::Url::parse("rtsp://administrator:@google.com/") {
    Ok(u) => u,
    Err(err) => {
        println!("'{}': {}", url, err);
        return;
     }
};
assert_eq!(url.password(), Some("")); // fails
url.set_password(Some(""));
assert_eq!(url.to_string(), "rtsp://administrator:@google.com/"); // passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions