diff --git a/CHANGELOG.md b/CHANGELOG.md index df621388..994e1f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/bugsnag/stacktrace.rb b/lib/bugsnag/stacktrace.rb index 344cd054..fd932a04 100644 --- a/lib/bugsnag/stacktrace.rb +++ b/lib/bugsnag/stacktrace.rb @@ -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