Skip to content

Commit

Permalink
Fix stripping Gem paths with Regexp characters
Browse files Browse the repository at this point in the history
e.g. the 3.2 RC contains a '+' in the gem path (at least locally and on
CI): `/../.gem/ruby/3.2.0+3`

This needs escaping or it won't match any paths because it is expecting
1 or more '0' characters, rather than the literal characters '0+'
  • Loading branch information
imjoehaines committed Dec 20, 2022
1 parent 9832c71 commit e94216a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Changelog

## TBD

### Fixes

* Allow Gem paths to be stripped from file names in stacktraces when they contain a Regexp special character
| [#764](https://github.com/bugsnag/bugsnag-ruby/pull/764)

### Enhancements

* Use `Exception#detailed_message` instead of `Exception#message` when available
Expand Down
4 changes: 3 additions & 1 deletion lib/bugsnag/stacktrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def self.process(backtrace, configuration)

# Strip common gem path prefixes
if defined?(Gem)
file = Gem.path.inject(file) {|line, path| line.sub(/#{path}\//, "") }
Gem.path.each do |path|
file.sub!("#{path}/", "")
end
end

trace_hash[:file] = file
Expand Down

0 comments on commit e94216a

Please sign in to comment.