From 9cbc24fce550d9a07b71ac2873f001cb3fc5a2ae Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 7 Sep 2014 13:00:06 -0700 Subject: [PATCH] More safety. :lock: --- lib/jekyll/cleaner.rb | 4 ++-- lib/jekyll/draft.rb | 2 +- lib/jekyll/static_file.rb | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/cleaner.rb b/lib/jekyll/cleaner.rb index 1786a317..6dd59ea0 100644 --- a/lib/jekyll/cleaner.rb +++ b/lib/jekyll/cleaner.rb @@ -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 diff --git a/lib/jekyll/draft.rb b/lib/jekyll/draft.rb index 7b1d9aca..27f9d2a1 100644 --- a/lib/jekyll/draft.rb +++ b/lib/jekyll/draft.rb @@ -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 diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index 02087e49..cde539ef 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -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