I have URI that contains ##
(e.g. http://foo.com/bar##baz
) . Ruby's URI.parse
function throws an error when I try to parse it.
Are double hash marks forbidden in URIs? Or is the Ruby Parser too strict?
I have URI that contains ##
(e.g. http://foo.com/bar##baz
) . Ruby's URI.parse
function throws an error when I try to parse it.
Are double hash marks forbidden in URIs? Or is the Ruby Parser too strict?
Fragment Identifiers may not contain a hash sign. The parser is correct.
The syntax for a fragment identifier is defined as follows:
fragment = *( pchar / "/" / "?" )
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved
, pct-encoded
and sub-delims
are defined as:
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded = "%" HEXDIG HEXDIG
sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
They are invalid. A #
indicates that the remainder is a fragment, and a fragment may not have a #
in it.
Addressable allows it:
require 'addressable/uri'
Addressable::URI.parse('http://foo.com/bar##baz').fragment
#=> "#baz"
Addressable is supposed to conform more closely to the rfc's, but wko knows. I would say it's subject to interpretation.
© 2022 - 2024 — McMap. All rights reserved.