Deleting custom header deletes all custom headers
- Dominant language
- Ruby
- Stars
- 74
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
In the following example notice how 'custom2' header is deleted while deleting 'custom1':
```
>> m=Mail.new :custom1 => 'test1', :custom2 => 'test2'
=> \#, >
>> m[:custom2]
=> #>
>> m[:custom1] = nil
=> nil
>> m[:custom2]
=> nil
```
The problem is caused by Mail::Field#<=> method. This method treats all custom fields as equal.
Quick monkey patch:
```
class Mail::Field
def <=>( other )
self_order = FIELD_ORDER.rindex(self.name.to_s.downcase) || 100
other_order = FIELD_ORDER.rindex(other.name.to_s.downcase) || 100
if self_order == 100 && self_order == other_order
self.name.to_s.downcase <=> other.name.to_s.downcase
else
self_order <=> other_order
end
end
end
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at Mail::Field#<=>, which the report identifies as treating all custom fields as equal, and reproduce the example with custom1 and custom2. Done means deleting custom1 no longer deletes custom2, while custom-field ordering remains distinct.
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