diff options
author | Neil Souza <neil@ztkae.com> | 2017-07-26 19:13:13 +0800 |
---|---|---|
committer | Gannon McGibbon <gannon.mcgibbon@shopify.com> | 2018-05-04 10:47:18 -0400 |
commit | bfddb67197bf0b5c6ec17e2a35ece9190bec8bac (patch) | |
tree | d159d902adcc478ea82939cab161aa4201e7f10a /activesupport/lib | |
parent | 98c1432583d4607af1467425183d8d448a692c5a (diff) | |
download | rails-bfddb67197bf0b5c6ec17e2a35ece9190bec8bac.tar.gz rails-bfddb67197bf0b5c6ec17e2a35ece9190bec8bac.tar.bz2 rails-bfddb67197bf0b5c6ec17e2a35ece9190bec8bac.zip |
Fix #29632 - nil #path leads to NoMethodError in LoadError#is_missing?
See #29632 for details. In short, it's possible to enter `LoadError#is_missing?` when `LoadError#path` returns `nil`, leading to `path.sub` throwing an none-to-helpful `NoMethodError`.
This tiniest of patch inserts `#to_s` before the `sub` call to make sure it succeeds. Affected surface area should be just as tiny since something has already gone wrong to get us into `#is_missing?` and the current behavior when `#path` returns `nil` seems clearly not intended.
[Gannon McGibbon + Neil Souza]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/load_error.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb index 750f858fcc..6b0dcab905 100644 --- a/activesupport/lib/active_support/core_ext/load_error.rb +++ b/activesupport/lib/active_support/core_ext/load_error.rb @@ -4,6 +4,6 @@ class LoadError # Returns true if the given path name (except perhaps for the ".rb" # extension) is the missing file which caused the exception to be raised. def is_missing?(location) - location.sub(/\.rb$/, "".freeze) == path.sub(/\.rb$/, "".freeze) + location.sub(/\.rb$/, "".freeze) == path.to_s.sub(/\.rb$/, "".freeze) end end |