Skip to content

Can angle brackets be used in a URL? #549

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

Closed
fboulnois opened this issue Sep 20, 2019 · 2 comments
Closed

Can angle brackets be used in a URL? #549

fboulnois opened this issue Sep 20, 2019 · 2 comments

Comments

@fboulnois
Copy link

I checked the relevant RFCs but maybe I missed if this was legitimate or not. I would expect URLs which contain angle brackets <> to cause a parse error.

  • In RFC1738, angle brackets are treated as unsafe and "must always be encoded within a URL" (section 2.2)
  • In RFC2396, URIs exclude angle brackets specifically (section 2.4.3)
  • In RFC3986, the allowed character set for the various URI components doesn't include angle brackets (sections 2 and 3), and in Appendix C, it is recommended that "using <> angle brackets around each URI is especially recommended as a delimiting style for a reference that contains embedded whitespace.", which suggests to me that angle brackets are explicitly excluded from the URI character set

Short example code:

extern crate url;
use url::Url;
fn main() {
    let s = "http://www.exam<ple.com";
    match Url::parse(s) {
        Ok(u) => println!("success: {}", u),
        Err(e) => panic!("failure: {}", e)
    }
}

output: success: http://www.exam<ple.com/

For what it's worth, in Firefox, new URL("http://exam<ple.com/") returns TypeError: http://exam<ple.com/ is not a valid URL.

@SimonSapin
Copy link
Member

This library implements the WHATWG URL Standard, not any IETF RFC. That said, it’s quite possible that the spec has changed and this implementation hasn’t caught up yet: #163, #290.

Also note that the normative requirement for a tool (or human) that produces an URL string may be different from those for a different tool that parses such a string.

@fboulnois
Copy link
Author

fboulnois commented Sep 20, 2019

This library implements the WHATWG URL Standard, not any IETF RFC. That said, it’s quite possible that the spec has changed and this implementation hasn’t caught up yet: #163, #290.

Also note that the normative requirement for a tool (or human) that produces an URL string may be different from those for a different tool that parses such a string.

That makes sense, thanks. whatwg-url validates http://www.exam<ple.com/ successfully too.

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

2 participants