From 7512e6bb66d72ff4d3ae13f31e236850bb580180 Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Mon, 4 Feb 2013 17:16:01 +0100 Subject: [PATCH 1/3] Allow symlinked folders in unsafe mode --- lib/jekyll/site.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 2deae484..22e08fd1 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -253,7 +253,7 @@ module Jekyll end # Private: creates a regular expression from the keep_files array - # + # # Examples # ['.git','.svn'] creates the following regex: /\/(\.git|\/.svn)/ # @@ -338,7 +338,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 From 4cd7c22ee704fde1fe7f798674f1a68f07c743c3 Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Mon, 4 Feb 2013 22:17:03 +0100 Subject: [PATCH 2/3] Now uses the more semantically correct AND operator --- lib/jekyll/site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 22e08fd1..5c1bd74e 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -338,7 +338,7 @@ module Jekyll ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.glob_include?(e) || - (File.symlink?(e) & self.safe) + (File.symlink?(e) && self.safe) end end end From 849c34e913b6ed65991e95c830ea5f8de41e0a30 Mon Sep 17 00:00:00 2001 From: Paul Leitmanis Date: Wed, 27 Feb 2013 10:39:46 +1100 Subject: [PATCH 3/3] Add tests for filtering symlink entries when safe mode enabled --- test/test_site.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_site.rb b/test/test_site.rb index c698a887..bc6ddb93 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -166,6 +166,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