Merge pull request #2420 from albertogg/fix-encoding-issue
This commit is contained in:
commit
7e05b6e0b3
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# encoding: utf-8
|
||||
|
||||
require 'helper'
|
||||
|
||||
class TestPost < Test::Unit::TestCase
|
||||
|
@ -100,6 +102,14 @@ class TestPost < Test::Unit::TestCase
|
|||
assert_equal "/2014/03/22/escape-+ %20[]", @post.id
|
||||
end
|
||||
|
||||
should "return a UTF-8 escaped string" do
|
||||
assert_equal Encoding::UTF_8, URL.escape_path("/rails笔记/2014/04/20/escaped/").encoding
|
||||
end
|
||||
|
||||
should "return a UTF-8 unescaped string" do
|
||||
assert_equal Encoding::UTF_8, URL.unescape_path("/rails%E7%AC%94%E8%AE%B0/2014/04/20/escaped/".encode(Encoding::ASCII)).encoding
|
||||
end
|
||||
|
||||
should "respect permalink in yaml front matter" do
|
||||
file = "2008-12-03-permalinked-post.textile"
|
||||
@post.process(file)
|
||||
|
|
Loading…
Reference in New Issue