mikel / mikel/mail

Method ::Mail::AttachmentsList#[]= clobbers hash assigned

Open
#644 1 comment 0 reactions 0 assignees View on GitHub
Bug More Work Needed
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.