Fix handling of source-dest matching being too aggressive

Fixes #1130.
This commit is contained in:
maul.esel 2013-09-16 14:41:20 +02:00
parent f606d9339b
commit bec4a07c12
1 changed files with 12 additions and 5 deletions

View File

@ -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