From 9932eb667bf9ceb543ff274ddf0d5ced6ee6b4e4 Mon Sep 17 00:00:00 2001 From: Alberto Grespan Date: Sat, 17 May 2014 17:53:40 -0430 Subject: [PATCH] Encode URLs in utf-8 when escaping and unescaping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is a problem while returning a path that has some special and possible Non-ASCII characters that may lead jekyll to break while doing the unescaping process. This is can be addressed by “forcing” ASCII to UTF-8. --- 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 8cd47242..f4ea4d33 100644 --- a/lib/jekyll/url.rb +++ b/lib/jekyll/url.rb @@ -89,7 +89,7 @@ module Jekyll # pct-encoded = "%" HEXDIG HEXDIG # sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # / "*" / "+" / "," / ";" / "=" - URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/) + URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/).encode('utf-8') end # Unescapes a URL path segment @@ -103,7 +103,7 @@ module Jekyll # # Returns the unescaped path. def self.unescape_path(path) - URI.unescape(path) + URI.unescape(path.encode('utf-8')) end end end