More safety. 🔒

This commit is contained in:
Parker Moore 2014-09-07 13:00:06 -07:00
parent 4078bde3ba
commit 9cbc24fce5
3 changed files with 5 additions and 4 deletions

View File

@ -29,7 +29,7 @@ module Jekyll
# Returns a Set with the file paths
def existing_files
files = Set.new
Dir.glob(File.join(site.dest, "**", "*"), File::FNM_DOTMATCH) do |file|
Dir.glob(site.in_dest_dir("**", "*"), File::FNM_DOTMATCH) do |file|
files << file unless file =~ /\/\.{1,2}$/ || file =~ keep_file_regex || keep_dirs.include?(file)
end
files
@ -76,7 +76,7 @@ module Jekyll
#
# Returns a Set with the directory paths
def keep_dirs
site.keep_files.map { |file| parent_dirs(File.join(site.dest, file)) }.flatten.to_set
site.keep_files.map { |file| parent_dirs(site.in_dest_dir(file)) }.flatten.to_set
end
# Private: Creates a regular expression from the config's keep_files array

View File

@ -15,7 +15,7 @@ module Jekyll
# Get the full path to the directory containing the draft files
def containing_dir(source, dir)
File.join(source, dir, '_drafts')
Jekyll.sanitized_path(source, File.join(dir, '_drafts'))
end
# The path to the draft source file, relative to the site source

View File

@ -37,7 +37,8 @@ module Jekyll
#
# Returns destination file path.
def destination(dest)
File.join(*[dest, destination_rel_dir, @name].compact)
dest = site.in_dest_dir(dest)
Jekyll.sanitized_path(dest, File.join(*[destination_rel_dir, @name].compact))
end
def destination_rel_dir