Skip to content
Browse files

Better handling of in file templates

`__END__` in the middle of lines should not be recognized as the end of
the ruby script. Ruby only accepts the line just contain `__END__`.
Beginning/tailing whitespaces are not allowed.

Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information...
1 parent b88c0f5 commit 64d852ea6f30ca4264f329415426d6cd2ebc7ae6 Yoji Shidara committed with rtomayko
Showing with 3 additions and 1 deletion.
  1. +1 −1 lib/sinatra/base.rb
  2. +2 −0 test/templates_test.rb
View
2 lib/sinatra/base.rb
@@ -637,7 +637,7 @@ def use_in_file_templates!(file=nil)
file ||= caller_files.first
begin
- data = ::IO.read(file).split('__END__')[1]
+ data = ::IO.read(file).split(/^__END__$/)[1]
rescue
data = nil
end
View
2 test/templates_test.rb
@@ -87,6 +87,8 @@ def with_default_layout
end
end
+# __END__ : this is not the real end of the script.
+
__END__
@@ foo

0 comments on commit 64d852e

Please sign in to comment.
Something went wrong with that request. Please try again.