Better error message for invalid post date.

This commit is contained in:
Tom Preston-Werner 2011-03-11 17:52:25 -08:00
parent 6c94db1486
commit dce4ccc5a4
4 changed files with 15 additions and 1 deletions

View File

@ -7,6 +7,8 @@
* Use English library to avoid hoops (#292) * Use English library to avoid hoops (#292)
* Add Posterous importer (#254) * Add Posterous importer (#254)
* Fixes for Wordpress importer (#274, #252, #271) * Fixes for Wordpress importer (#274, #252, #271)
* Better error message for invalid post date (#291)
* Print formatted fatal exceptions to stdout on build failure
* Bug Fixes * Bug Fixes
* Secure additional path exploits * Secure additional path exploits

View File

@ -242,7 +242,11 @@ else
puts "Building site: #{source} -> #{destination}" puts "Building site: #{source} -> #{destination}"
begin begin
site.process site.process
rescue Jekyll::FatalException rescue Jekyll::FatalException => e
puts
puts "ERROR: YOUR SITE COULD NOT BE BUILT:"
puts "------------------------------------"
puts e.message
exit(1) exit(1)
end end
puts "Successfully generated site: #{source} -> #{destination}" puts "Successfully generated site: #{source} -> #{destination}"

View File

@ -78,6 +78,8 @@ module Jekyll
self.date = Time.parse(date) self.date = Time.parse(date)
self.slug = slug self.slug = slug
self.ext = ext self.ext = ext
rescue ArgumentError
raise FatalException.new("Post #{name} does not have a valid date.")
end end
# The generated directory into which the post will be placed # The generated directory into which the post will be placed

View File

@ -52,6 +52,12 @@ class TestPost < Test::Unit::TestCase
assert_equal "/2008/09/09/foo-bar.html", @post.url assert_equal "/2008/09/09/foo-bar.html", @post.url
end end
should "raise a good error on invalid post date" do
assert_raise Jekyll::FatalException do
@post.process("2009-27-03-foo-bar.textile")
end
end
should "CGI escape urls" do should "CGI escape urls" do
@post.categories = [] @post.categories = []
@post.process("2009-03-12-hash-#1.markdown") @post.process("2009-03-12-hash-#1.markdown")