Skip to content

Url::set_path can break roundtripping #1123

Description

@Scripter17
  • Note that this crate implements the very badly designed URL Standard not RFC 1738 or RFC 3986
// Trailing spaces are removed
let mut a = url::Url::parse("a:  ").unwrap();
// But Url::set_path doesn't
a.set_path("  ");
// Which breaks roundtripping.
assert_ne!(url::Url::parse(a.as_str()).unwrap(), url);
// And makes setting the query/fragment to themselves not no-ops.
a.set_query(None);
assert_eq!(a.as_str(), "a:");

See whatwg/url#909 for discussion on if setting the state override to opaque path is even valid.

I think the behavior should be to always replace a trailing space with %20. a: ? is already supposed to result in a: %20? (though currently doesn't...). AFAIK this should also remove the strip maybe trailing spaces code from the query and fragment setters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions