Fix Page#url escape
Post#url wasn't escaped at all. For example, when we have a page named 'a#b.html', we expect its url to be 'a%23b.html', but it was actually 'a#b.html'. We now use Jekyll::URL.escape_path and Jekyll::URL.unescape_path.
This commit is contained in:
parent
eebb6414bf
commit
e3e1c11509
|
@ -86,8 +86,8 @@ module Jekyll
|
|||
# desired placeholder replacements. For details see "url.rb"
|
||||
def url_placeholders
|
||||
{
|
||||
:path => @dir,
|
||||
:basename => basename,
|
||||
:path => URL.escape_path(@dir),
|
||||
:basename => URL.escape_path(basename),
|
||||
:output_ext => output_ext
|
||||
}
|
||||
end
|
||||
|
@ -135,7 +135,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the destination file path String.
|
||||
def destination(dest)
|
||||
path = Jekyll.sanitized_path(dest, url)
|
||||
path = Jekyll.sanitized_path(dest, URL.unescape_path(url))
|
||||
path = File.join(path, "index.html") if url =~ /\/$/
|
||||
path
|
||||
end
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
layout: default
|
||||
title : Page name with non-alphabetic character
|
||||
---
|
||||
Line 1
|
||||
{{ page.title }}
|
|
@ -125,7 +125,7 @@ class TestFilters < Test::Unit::TestCase
|
|||
case g["name"]
|
||||
when "default"
|
||||
assert g["items"].is_a?(Array), "The list of grouped items for 'default' is not an Array."
|
||||
assert_equal 4, g["items"].size
|
||||
assert_equal 5, g["items"].size
|
||||
when "nil"
|
||||
assert g["items"].is_a?(Array), "The list of grouped items for 'nil' is not an Array."
|
||||
assert_equal 2, g["items"].size
|
||||
|
|
|
@ -30,6 +30,11 @@ class TestPage < Test::Unit::TestCase
|
|||
assert_equal false, @page.published?
|
||||
end
|
||||
|
||||
should "create url with non-alphabetic characters" do
|
||||
@page = setup_page('+', '%# +.md')
|
||||
assert_equal "/+/%25%23%20+.html", @page.url
|
||||
end
|
||||
|
||||
context "in a directory hierarchy" do
|
||||
should "create url based on filename" do
|
||||
@page = setup_page('/contacts', 'bar.html')
|
||||
|
@ -174,6 +179,15 @@ class TestPage < Test::Unit::TestCase
|
|||
assert File.exists?(File.join(dest_dir, '+', 'plus+in+url'))
|
||||
end
|
||||
|
||||
should "write even when permalink has '%# +'" do
|
||||
page = setup_page('+', '%# +.md')
|
||||
do_render(page)
|
||||
page.write(dest_dir)
|
||||
|
||||
assert File.directory?(dest_dir)
|
||||
assert File.exists?(File.join(dest_dir, '+', '%# +.html'))
|
||||
end
|
||||
|
||||
should "write properly without html extension" do
|
||||
page = setup_page('contacts.html')
|
||||
page.site.permalink_style = :pretty
|
||||
|
|
|
@ -159,6 +159,7 @@ class TestSite < Test::Unit::TestCase
|
|||
@site.process
|
||||
# files in symlinked directories may appear twice
|
||||
sorted_pages = %w(
|
||||
%#\ +.md
|
||||
.htaccess
|
||||
about.html
|
||||
bar.html
|
||||
|
|
Loading…
Reference in New Issue