https://github.com/rails/rails/issues/40196 https://github.com/rails/web-console/issues/301f38
parent
a1df3525a9
commit
9bedb8bdc2
@ -0,0 +1,28 @@
|
|||||||
|
From 5611f4b430881bcfa788044ff3f42118370c61a2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jonathan Hefner <jonathan@hefner.pro>
|
||||||
|
Date: Mon, 7 Sep 2020 16:44:21 -0500
|
||||||
|
Subject: [PATCH] Anchor BacktraceCleaner gem filter regexp
|
||||||
|
|
||||||
|
This ensures the default gem filter does not affect backtrace lines that
|
||||||
|
have a subpath incidentally matching a gem path.
|
||||||
|
|
||||||
|
Fixes #40196.
|
||||||
|
---
|
||||||
|
activesupport/test/clean_backtrace_test.rb | 6 ++++++
|
||||||
|
1 files changed, 6 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb
|
||||||
|
index a846312d68f2..dd62ef359b73 100644
|
||||||
|
--- a/activesupport/test/clean_backtrace_test.rb
|
||||||
|
+++ b/activesupport/test/clean_backtrace_test.rb
|
||||||
|
@@ -124,4 +124,10 @@ def setup
|
||||||
|
result = @bc.clean(backtrace)
|
||||||
|
assert_empty result
|
||||||
|
end
|
||||||
|
+
|
||||||
|
+ test "should preserve lines that have a subpath matching a gem path" do
|
||||||
|
+ backtrace = [Gem.default_dir, *Gem.path].map { |path| "/parent#{path}/gems/nosuchgem-1.2.3/lib/foo.rb" }
|
||||||
|
+
|
||||||
|
+ assert_equal backtrace, @bc.clean(backtrace)
|
||||||
|
+ end
|
||||||
|
end
|
@ -0,0 +1,26 @@
|
|||||||
|
From 5611f4b430881bcfa788044ff3f42118370c61a2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jonathan Hefner <jonathan@hefner.pro>
|
||||||
|
Date: Mon, 7 Sep 2020 16:44:21 -0500
|
||||||
|
Subject: [PATCH] Anchor BacktraceCleaner gem filter regexp
|
||||||
|
|
||||||
|
This ensures the default gem filter does not affect backtrace lines that
|
||||||
|
have a subpath incidentally matching a gem path.
|
||||||
|
|
||||||
|
Fixes #40196.
|
||||||
|
---
|
||||||
|
activesupport/lib/active_support/backtrace_cleaner.rb | 2 +-
|
||||||
|
1 files changed, 1 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/activesupport/lib/active_support/backtrace_cleaner.rb b/activesupport/lib/active_support/backtrace_cleaner.rb
|
||||||
|
index ad80b8855f3f..405db9a6fe6c 100644
|
||||||
|
--- a/activesupport/lib/active_support/backtrace_cleaner.rb
|
||||||
|
+++ b/activesupport/lib/active_support/backtrace_cleaner.rb
|
||||||
|
@@ -91,7 +91,7 @@ def add_gem_filter
|
||||||
|
gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) }
|
||||||
|
return if gems_paths.empty?
|
||||||
|
|
||||||
|
- gems_regexp = %r{(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)}
|
||||||
|
+ gems_regexp = %r{\A(#{gems_paths.join('|')})/(bundler/)?gems/([^/]+)-([\w.]+)/(.*)}
|
||||||
|
gems_result = '\3 (\4) \5'
|
||||||
|
add_filter { |line| line.sub(gems_regexp, gems_result) }
|
||||||
|
end
|
Loading…
Reference in new issue