diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-01-27 20:45:35 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-01-27 20:45:35 +0000 |
commit | c155fe9a3910fe3ab2e9cabe0ceb1c44fab31d72 (patch) | |
tree | 277e11a52dd0eb310e1a26342852e023e7d43566 | |
parent | 9500ad5fbc337d881dc953631f6d808ad08774c1 (diff) | |
download | rails-c155fe9a3910fe3ab2e9cabe0ceb1c44fab31d72.tar.gz rails-c155fe9a3910fe3ab2e9cabe0ceb1c44fab31d72.tar.bz2 rails-c155fe9a3910fe3ab2e9cabe0ceb1c44fab31d72.zip |
Precalculate the Backtrace of a template error to avoid raising exceptions in TemplateError#backtrace. These will abort the ruby vm. Closes #10936 [Aleksey Kondratenko]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8743 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_view/template_error.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/template_error.rb b/actionpack/lib/action_view/template_error.rb index 01b4b15550..54e4cf099d 100644 --- a/actionpack/lib/action_view/template_error.rb +++ b/actionpack/lib/action_view/template_error.rb @@ -10,6 +10,7 @@ module ActionView @base_path, @assigns, @source, @original_exception = base_path, assigns.dup, source, original_exception @file_path = file_path + @backtrace = compute_backtrace end def message @@ -72,14 +73,20 @@ module ActionView "#{source_extract}\n #{clean_backtrace.join("\n ")}\n\n" end + # don't do anything nontrivial here. Any raised exception from here becomes fatal + # (and can't be rescued). def backtrace - [ - "#{source_location.capitalize}\n\n#{source_extract(4)}\n " + - clean_backtrace.join("\n ") - ] + @backtrace end private + def compute_backtrace + [ + "#{source_location.capitalize}\n\n#{source_extract(4)}\n " + + clean_backtrace.join("\n ") + ] + end + def strip_base_path(path) stripped_path = File.expand_path(path).gsub(@base_path, "") stripped_path.gsub!(/^#{Regexp.escape File.expand_path(RAILS_ROOT)}/, '') if defined?(RAILS_ROOT) |