From bec4a07c1287df0f1194d2fd5be55a9e5fa4c1e3 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Mon, 16 Sep 2013 14:41:20 +0200 Subject: [PATCH] Fix handling of source-dest matching being too aggressive Fixes #1130. --- lib/jekyll/site.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index f4a5bd0d..ef7be1fc 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -63,11 +63,7 @@ module Jekyll # # Returns nothing. def setup - # Check that the destination dir isn't the source dir or a directory - # parent to the source dir. - if self.source =~ /^#{self.dest}/ - raise FatalException.new "Destination directory cannot be or contain the Source directory." - end + ensure_not_in_dest # If safe mode is off, load in any Ruby files under the plugins # directory. @@ -83,6 +79,17 @@ module Jekyll self.generators = instantiate_subclasses(Jekyll::Generator) end + # Check that the destination dir isn't the source dir or a directory + # parent to the source dir. + def ensure_not_in_dest + dest = Pathname.new(self.dest) + Pathname.new(self.source).ascend do |path| + if path == dest + raise FatalException.new "Destination directory cannot be or contain the Source directory." + end + end + end + # Internal: Setup the plugin search path # # Returns an Array of plugin search paths