Do not treat colons in `url_placeholders` as URI delimiters (#9850)
Merge pull request 9850
This commit is contained in:
parent
55024b37ae
commit
76982c73c0
|
@ -144,7 +144,13 @@ module Jekyll
|
|||
# pct-encoded = "%" HEXDIG HEXDIG
|
||||
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
||||
# / "*" / "+" / "," / ";" / "="
|
||||
Addressable::URI.encode(path).encode("utf-8").sub("#", "%23")
|
||||
#
|
||||
# `Addressable::URI::CharacterClassesRegexps::PATH` is used to encode
|
||||
# non-alphanumeric characters such as "[", "]", etc.
|
||||
Addressable::URI.encode_component(
|
||||
path,
|
||||
Addressable::URI::CharacterClassesRegexps::PATH
|
||||
).encode("utf-8").sub("#", "%23")
|
||||
end
|
||||
|
||||
# Unescapes a URL path segment
|
||||
|
|
|
@ -80,5 +80,16 @@ class TestURL < JekyllUnitTest
|
|||
).to_s
|
||||
end
|
||||
end
|
||||
|
||||
should "not treat colons in placeholders as uri delimiters" do
|
||||
assert_equal "/foo/foo%20bar:foobar/", URL.new(
|
||||
:template => "/:x/:y/",
|
||||
:placeholders => { :x => "foo", :y => "foo bar:foobar" }
|
||||
).to_s
|
||||
end
|
||||
|
||||
should "unescape urls with colons" do
|
||||
assert_equal "/foo/foo bar:foobar/", Jekyll::URL.unescape_path("/foo/foo%20bar:foobar/")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue