Merge pull request #824 from sinamt/symlinked_folders

Allow symlinked folders in unsafe mode (with tests). Closes #796, resolves #233.
This commit is contained in:
Parker Moore 2013-02-26 16:54:52 -08:00
commit 63d0eef646
2 changed files with 18 additions and 2 deletions

View File

@ -264,7 +264,7 @@ module Jekyll
end end
# Private: creates a regular expression from the keep_files array # Private: creates a regular expression from the keep_files array
# #
# Examples # Examples
# ['.git','.svn'] creates the following regex: /\/(\.git|\/.svn)/ # ['.git','.svn'] creates the following regex: /\/(\.git|\/.svn)/
# #
@ -349,7 +349,7 @@ module Jekyll
['.', '_', '#'].include?(e[0..0]) || ['.', '_', '#'].include?(e[0..0]) ||
e[-1..-1] == '~' || e[-1..-1] == '~' ||
self.exclude.glob_include?(e) || self.exclude.glob_include?(e) ||
File.symlink?(e) (File.symlink?(e) && self.safe)
end end
end end
end end

View File

@ -172,6 +172,22 @@ class TestSite < Test::Unit::TestCase
assert_equal files, @site.filter_entries(files) assert_equal files, @site.filter_entries(files)
end end
should "filter symlink entries when safe mode enabled" do
stub(Jekyll).configuration do
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'safe' => true})
end
site = Site.new(Jekyll.configuration)
stub(File).symlink?('symlink.js') {true}
files = %w[symlink.js]
assert_equal [], site.filter_entries(files)
end
should "not filter symlink entries when safe mode disabled" do
stub(File).symlink?('symlink.js') {true}
files = %w[symlink.js]
assert_equal files, @site.filter_entries(files)
end
context 'error handling' do context 'error handling' do
should "raise if destination is included in source" do should "raise if destination is included in source" do
stub(Jekyll).configuration do stub(Jekyll).configuration do