Do not treat colons in `url_placeholders` as URI delimiters (#9850)

Merge pull request 9850
This commit is contained in:
fauno 2025-07-11 09:07:17 -03:00 committed by GitHub
parent 55024b37ae
commit 76982c73c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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