Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\ characters should be escaped in paths of special URLs #468

Closed
sfackler opened this issue Nov 6, 2018 · 1 comment
Closed

\ characters should be escaped in paths of special URLs #468

sfackler opened this issue Nov 6, 2018 · 1 comment

Comments

@sfackler
Copy link
Contributor

sfackler commented Nov 6, 2018

\ characters are not escaped when appended to paths currently:

let mut url = "http://foobar.com".parse::<Url>().unwrap();
url.path_segments_mut().unwrap().push("foo\\bar");
assert_eq!(url.as_str(), "http://foobar.com/foo\\bar");

However, the path-state section of the URL standard treats \ as a path separator and a validation error in special URLs. I believe push should be percent-encoding the \ to %5C.

@sfackler
Copy link
Contributor Author

sfackler commented Nov 6, 2018

This causes some extra fun, since the parser does handle \ properly, so a URL constructed via push has a different number of path components than the same URL reparsed: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=288a9f492fdd1bcb9c2afaefa7ebca5b

sfackler added a commit to sfackler/rust-url that referenced this issue Nov 6, 2018
bors-servo pushed a commit that referenced this issue Nov 6, 2018
Escape backslash in special URL path components

Closes #468

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/469)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant