Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2-0-stable: Precalculate the Backtrace of a template error to avoid r…

…aising exceptions in TemplateError#backtrace. These will abort the ruby vm. References #10936 [Aleksey Kondratenko]

Merging [8743]


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/2-0-stable@8835 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit a9113b8895bfa634fd8622a9c6ab00cd1fa99048 1 parent b1aa674
@NZKoz NZKoz authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 actionpack/lib/action_view/template_error.rb
View
15 actionpack/lib/action_view/template_error.rb
@@ -10,6 +10,7 @@ def initialize(base_path, file_path, assigns, source, original_exception)
@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 @@ def to_s
"#{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)
Please sign in to comment.
Something went wrong with that request. Please try again.