Prevent _includes dir from being a symlink.

This commit is contained in:
Tom Preston-Werner 2010-11-22 21:45:35 -08:00
parent 61acd47ed2
commit 3ab016870d
2 changed files with 8 additions and 1 deletions

View File

@ -9,6 +9,7 @@
* Bug Fixes
* Fixed filename basename generation (#208)
* Set mode to UTF8 on Sequel connections (#237)
* Prevent _includes dir from being a symlink
== 0.7.0 / 2010-08-24
* Minor Enhancements

View File

@ -7,11 +7,17 @@ module Jekyll
end
def render(context)
includes_dir = File.join(context.registers[:site].source, '_includes')
if File.symlink?(includes_dir)
return "Includes directory '#{includes_dir}' cannot be a symlink"
end
if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
return "Include file '#{@file}' contains invalid characters or sequences"
end
Dir.chdir(File.join(context.registers[:site].source, '_includes')) do
Dir.chdir(includes_dir) do
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
if choices.include?(@file)
source = File.read(@file)