Merge pull request #909 from x3ro/symlinked-static-files

Fix symlinked static files not being correctly built in unsafe mode
This commit is contained in:
Parker Moore 2013-04-03 14:10:35 -07:00
commit cf461ea1a5
4 changed files with 25 additions and 1 deletions

View File

@ -159,7 +159,7 @@ module Jekyll
if File.directory?(f_abs)
next if self.dest.sub(/\/$/, '') == f_abs
read_directories(f_rel)
elsif !File.symlink?(f_abs)
else
first3 = File.open(f_abs) { |fd| fd.read(3) }
if first3 == "---"
# file appears to have a YAML header so process it as a page

View File

@ -0,0 +1 @@
../css

View File

@ -0,0 +1 @@
../index.html

View File

@ -217,6 +217,28 @@ class TestSite < Test::Unit::TestCase
assert_equal files, @site.filter_entries(files)
end
should "not include symlinks in safe mode" do
stub(Jekyll).configuration do
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'safe' => true})
end
site = Site.new(Jekyll.configuration)
site.read_directories("symlink-test")
assert_equal [], site.pages
assert_equal [], site.static_files
end
should "include symlinks in unsafe mode" do
stub(Jekyll).configuration do
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'safe' => false})
end
site = Site.new(Jekyll.configuration)
site.read_directories("symlink-test")
assert_not_equal [], site.pages
assert_not_equal [], site.static_files
end
context 'error handling' do
should "raise if destination is included in source" do
stub(Jekyll).configuration do