Blob Blame History Raw
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