Issue 7: CGI escape post titles
Signed-off-by: Nick Quaranto <nick@quaran.to>
This commit is contained in:
parent
a5d236eb53
commit
4bcece18ae
|
@ -127,7 +127,7 @@ module Jekyll
|
||||||
"year" => date.strftime("%Y"),
|
"year" => date.strftime("%Y"),
|
||||||
"month" => date.strftime("%m"),
|
"month" => date.strftime("%m"),
|
||||||
"day" => date.strftime("%d"),
|
"day" => date.strftime("%d"),
|
||||||
"title" => slug,
|
"title" => CGI.escape(slug),
|
||||||
"categories" => categories.sort.join('/')
|
"categories" => categories.sort.join('/')
|
||||||
}.inject(template) { |result, token|
|
}.inject(template) { |result, token|
|
||||||
result.gsub(/:#{token.first}/, token.last)
|
result.gsub(/:#{token.first}/, token.last)
|
||||||
|
@ -188,7 +188,8 @@ module Jekyll
|
||||||
def write(dest)
|
def write(dest)
|
||||||
FileUtils.mkdir_p(File.join(dest, dir))
|
FileUtils.mkdir_p(File.join(dest, dir))
|
||||||
|
|
||||||
path = File.join(dest, self.url)
|
# The url needs to be unescaped in order to preserve the correct filename
|
||||||
|
path = File.join(dest, CGI.unescape(self.url))
|
||||||
|
|
||||||
if template[/\.html$/].nil?
|
if template[/\.html$/].nil?
|
||||||
FileUtils.mkdir_p(path)
|
FileUtils.mkdir_p(path)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
title: Hash #1
|
||||||
|
---
|
||||||
|
|
||||||
|
Hashes are nice
|
|
@ -52,6 +52,13 @@ class TestPost < Test::Unit::TestCase
|
||||||
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "CGI escape urls" do
|
||||||
|
@post.categories = []
|
||||||
|
@post.process("2009-03-12-hash-#1.markdown")
|
||||||
|
assert_equal "/2009/03/12/hash-%231.html", @post.url
|
||||||
|
assert_equal "/2009/03/12/hash-#1", @post.id
|
||||||
|
end
|
||||||
|
|
||||||
should "respect permalink in yaml front matter" do
|
should "respect permalink in yaml front matter" do
|
||||||
file = "2008-12-03-permalinked-post.textile"
|
file = "2008-12-03-permalinked-post.textile"
|
||||||
@post.process(file)
|
@post.process(file)
|
||||||
|
|
Loading…
Reference in New Issue