From 25519b38f69b0baae0cf7e0cca31a60c3b792b18 Mon Sep 17 00:00:00 2001 From: Anatol Broder Date: Tue, 17 Sep 2013 20:57:01 +0200 Subject: [PATCH] Validate file name as soon as possible --- lib/jekyll/tags/include.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 143555c8..c4dea149 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -11,10 +11,11 @@ module Jekyll def initialize(tag_name, markup, tokens) super @file, @params = markup.strip.split(' ', 2); + validate_file_name end def parse_params(context) - validate_syntax + validate_params params = {} markup = @params @@ -35,12 +36,6 @@ module Jekyll params end - # ensure the entire markup string from start to end is valid syntax, and params are separated by spaces - def validate_syntax - validate_file_name - validate_params - end - def validate_file_name if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./ raise SyntaxError.new <<-eos