diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 74ebd112..f0ef9e68 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -264,7 +264,7 @@ module Jekyll end # Private: creates a regular expression from the keep_files array - # + # # Examples # ['.git','.svn'] creates the following regex: /\/(\.git|\/.svn)/ # @@ -349,7 +349,7 @@ module Jekyll ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.glob_include?(e) || - File.symlink?(e) + (File.symlink?(e) && self.safe) end end end diff --git a/test/test_site.rb b/test/test_site.rb index 64cc8437..84fc5c41 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -172,6 +172,22 @@ class TestSite < Test::Unit::TestCase assert_equal files, @site.filter_entries(files) 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 should "raise if destination is included in source" do stub(Jekyll).configuration do