-
Notifications
You must be signed in to change notification settings - Fork 937
Fix address with Q-encoded display name containing double quotes #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@grosser any concerns? |
hmm old logic sounds broken, more logic does not feel very clean either ... but at least we have a test ... so choosing between the two evils I'd pick the new code ... 👍 |
@grosser You are totally right that this is likely not the most appropriate fix. I just did a quick test not using the when :angle_addr_s
if phrase_e
phrase = s[phrase_s..phrase_e].strip
if phrase[0] == '"' && phrase[-1] == '"'
phrase = phrase[1..-2]
end
address.display_name = phrase
phrase_e = phrase_s = nil
end This questions the relevance of parsing quoted string as a token. |
I like that version more ... are there enough tests that you are comfortable with that change ? |
Sorry for the delay! Yes I am confident enough with the specs I just added for comments inside Q-encoded display names. |
Mmh not sure why specs fail on Travis. All green on my machine. Can someone have a look? |
I added a spec for parsing the following address:
Before the fix, display name was parsed as
Jan_Kr=FCtisch
because when a quoted string was found (ie."Jan_Kr=FCtisch"
), it was used as the display name and the surrounding characters were ignored.After the fix, display name is properly encoded as
Jan Krütisch
. Code-wise, theqstr
variable is now used as the display name instead ofphrase
only ifqstr
is equal tophrase
minus the quotes.I would have liked to avoid creating the
%("#{qstr}")
string, but I did not see another way. Other than that performance/memory should not be affected.