Encode URLs in utf-8 when escaping and unescaping

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.
This commit is contained in:
Alberto Grespan 2014-05-17 17:53:40 -04:30
parent ab679cbe26
commit 9932eb667b
1 changed files with 2 additions and 2 deletions

View File

@ -89,7 +89,7 @@ module Jekyll
# pct-encoded = "%" HEXDIG HEXDIG # pct-encoded = "%" HEXDIG HEXDIG
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" # sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
# / "*" / "+" / "," / ";" / "=" # / "*" / "+" / "," / ";" / "="
URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/) URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/).encode('utf-8')
end end
# Unescapes a URL path segment # Unescapes a URL path segment
@ -103,7 +103,7 @@ module Jekyll
# #
# Returns the unescaped path. # Returns the unescaped path.
def self.unescape_path(path) def self.unescape_path(path)
URI.unescape(path) URI.unescape(path.encode('utf-8'))
end end
end end
end end