From ec5b45cd7c1a2df1520ada1df9b235101ea11ba2 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 16 Mar 2017 07:54:13 -0500 Subject: [PATCH 1/2] Allow colons in `uri_escape` filter Fixes #5954 --- lib/jekyll/filters.rb | 2 +- test/test_filters.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 0393ea241d6..3020bfbcb6b 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -152,7 +152,7 @@ def cgi_escape(input) # # Returns the escaped String. def uri_escape(input) - Addressable::URI.encode(input) + Addressable::URI.normalize_component(input) end # Replace any whitespace in the input string with a single space diff --git a/test/test_filters.rb b/test/test_filters.rb index d18b57e3ef3..898f7e3ed90 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -317,6 +317,11 @@ def select; end assert_equal "my%20things", @filter.uri_escape("my things") end + should "escape colon" do + assert_equal "foo:bar", @filter.uri_escape("foo:bar") + assert_equal "foo%20bar:baz", @filter.uri_escape("foo bar:baz") + end + context "absolute_url filter" do should "produce an absolute URL from a page URL" do page_url = "/about/my_favorite_page/" From 6bc9f71050be590478d1d47b1050f4dddb5471f7 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 16 Mar 2017 07:59:13 -0500 Subject: [PATCH 2/2] Rename test for clarity --- test/test_filters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_filters.rb b/test/test_filters.rb index 898f7e3ed90..782b5be984f 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -317,7 +317,7 @@ def select; end assert_equal "my%20things", @filter.uri_escape("my things") end - should "escape colon" do + should "allow colons in URI" do assert_equal "foo:bar", @filter.uri_escape("foo:bar") assert_equal "foo%20bar:baz", @filter.uri_escape("foo bar:baz") end