Method ::Mail::AttachmentsList#[]= clobbers hash assigned
- Dominant language
- Ruby
- Stars
- 3.7k
- Forks
- 934
- PR merge metrics
- No merged PRs in 30d
Description
Mail::AttachmentsList#[]= , given a hash object to assign (instead of a literal hash), clobbers it (by deleting its key-value pairs). (Here is a tiny example [gist](https://gist.github.com/MarkDBlackwell/7897447).)
Clobbering this hash object in this assignment seems to violate [POLS](http://en.wikipedia.org/wiki/Principle_of_least_astonishment) (the Principle Of Least Surprise).
This problem IMHO could be avoided best here (on [this line](https://github.com/mikel/mail/blob/8e455b910607d439e1b369df0d66de8e3f7f707e/lib/mail/attachments_list.rb#L46)) by adding:
value = value.dup
Contributor guide
Research direction
Start at lib/mail/attachments_list.rb, specifically the line 46 assignment described in the issue. Verify the behavior with a hash object rather than a literal hash, then ensure the assigned hash is not modified while the attachment list receives the expected value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100