Current 2-7-stable crashes on empty Keywords: header
- Dominant language
- Ruby
- Stars
- 3.7k
- Forks
- 934
- PR merge metrics
- No merged PRs in 30d
Description
On 2-7-stable an email with an empty `Keywords:` header will lead to the following error being raised:
```
> Mail::PhraseList.new("")
Mail::Field::IncompleteParseError: Mail::PhraseList can not parse ||: Only able to parse up to ""
```
We have developed and use a fix for 2-7-stable, if this should be added in an upcoming 2.7 release please let us know and we will prepare a pull request.
This is solved on master but untested. The following diff adds a test to the spec to make sure this continues to work on master:
```diff
diff --git a/spec/mail/fields/keywords_field_spec.rb b/spec/mail/fields/keywords_field_spec.rb
index e3e1caff..6b24e1b9 100644
--- a/spec/mail/fields/keywords_field_spec.rb
+++ b/spec/mail/fields/keywords_field_spec.rb
@@ -64,4 +64,9 @@ describe Mail::KeywordsField do
lines.each { |line| expect(line.length).to be < 998 }
end
+ it "should handle a blank value" do
+ k = Mail::KeywordsField.new('')
+ expect(k.decoded).to eq ''
+ expect(k.encoded).to eq "Keywords: \r\n"
+ end
end
```
Contributor guide
Research direction
Start with spec/mail/fields/keywords_field_spec.rb and run the existing KeywordsField specs on 2-7-stable. Reproduce an empty Keywords: value, compare the behavior with master, and verify the supplied blank-value expectations. Done means the empty header no longer raises and the added spec passes on the target branch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100