From 6fb05e07999e9dcd69eaf0597cb33ce10bda1b01 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 5 Jan 2017 17:44:54 -0600 Subject: [PATCH 1/3] Use Addressable instead of URI to decode --- lib/jekyll/filters.rb | 4 ++-- lib/jekyll/url.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 43e01df1..808632ba 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -1,4 +1,4 @@ -require "uri" +require "addressable/uri" require "json" require "date" require "liquid" @@ -152,7 +152,7 @@ module Jekyll # # Returns the escaped String. def uri_escape(input) - URI.escape(input) + Addressable::URI.encode(input) end # Replace any whitespace in the input string with a single space diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 4504574f..c630b539 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -1,3 +1,4 @@ +require "addressable/uri" require "uri" # Public: Methods that generate a URL for a resource such as a Post or a Page. @@ -159,7 +160,7 @@ module Jekyll # # Returns the unescaped path. def self.unescape_path(path) - URI.unescape(path.encode("utf-8")) + Addressable::URI.unencode(path.encode("utf-8")) end end end From 5652c10305f204299544869e95f41d3b5a451328 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 5 Jan 2017 18:01:00 -0600 Subject: [PATCH 2/3] Try to replace `URI.escape` with Addressable --- lib/jekyll/url.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index c630b539..072ea8cd 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -1,5 +1,4 @@ require "addressable/uri" -require "uri" # Public: Methods that generate a URL for a resource such as a Post or a Page. # @@ -146,7 +145,8 @@ module Jekyll # pct-encoded = "%" HEXDIG HEXDIG # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # / "*" / "+" / "," / ";" / "=" - URI.escape(path, %r{[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]}).encode("utf-8") + path = Addressable::URI.encode(path) + path.encode("utf-8") end # Unescapes a URL path segment From 1e4b779ab372f610fb6c510c7570122146357171 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Thu, 5 Jan 2017 18:34:44 -0600 Subject: [PATCH 3/3] Escape # --- lib/jekyll/url.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/url.rb b/lib/jekyll/url.rb index 072ea8cd..aefbebc9 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -146,7 +146,7 @@ module Jekyll # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # / "*" / "+" / "," / ";" / "=" path = Addressable::URI.encode(path) - path.encode("utf-8") + path.encode("utf-8").sub("#", "%23") end # Unescapes a URL path segment