diff options
author | George Claghorn <george@basecamp.com> | 2019-07-22 12:19:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-22 12:19:00 -0400 |
commit | 2af445c3118f7f22b8c28bf2287b193a647bbb10 (patch) | |
tree | 6a2d3bce2facb164321fa71aca52007fdfe5e45f /activesupport/lib | |
parent | 9ad806887096be1f60019a6b301a4c84aa1d8e65 (diff) | |
parent | 722c45f64110be876d83e7f9a22592aa954886c1 (diff) | |
download | rails-2af445c3118f7f22b8c28bf2287b193a647bbb10.tar.gz rails-2af445c3118f7f22b8c28bf2287b193a647bbb10.tar.bz2 rails-2af445c3118f7f22b8c28bf2287b193a647bbb10.zip |
Merge pull request #36623 from alipman88/exclude_marshal_dump_from_delegate_missing_to
Exclude marshal_dump & _dump methods from being delegated via delegate_missing_to extension, fix #36522
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/delegation.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 54271a3970..14d7f0c484 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -276,6 +276,11 @@ class Module # The delegated method must be public on the target, otherwise it will # raise +DelegationError+. If you wish to instead return +nil+, # use the <tt>:allow_nil</tt> option. + # + # The <tt>marshal_dump</tt> and <tt>_dump</tt> methods are exempt from + # delegation due to possible interference when calling + # <tt>Marshal.dump(object)</tt>, should the delegation target method + # of <tt>object</tt> add or remove instance variables. def delegate_missing_to(target, allow_nil: nil) target = target.to_s target = "self.#{target}" if DELEGATION_RESERVED_METHOD_NAMES.include?(target) @@ -285,6 +290,7 @@ class Module # It may look like an oversight, but we deliberately do not pass # +include_private+, because they do not get delegated. + return false if name == :marshal_dump || name == :_dump #{target}.respond_to?(name) || super end |