Escape a backslash in a quoted display name - #68
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
`Address.with_name` quoted a display name that held a special character but
only escaped `"` inside it, never `\`. Two consequences, both producing an
invalid From/To header:
- A name ending in `\` ("Smith, John\") escaped the closing quote, so the
quoted string ran on into the address.
- A `\` anywhere else ("C:\Users") was read by a parser as a quoted-pair and
silently dropped the following character.
`\` is also added to the set that triggers quoting, so a bare backslash in an
otherwise plain name no longer goes out as an unquoted atom.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address.with_namequotes a display name when it contains a special character, butquote_escapedonly escaped"inside the quoted string — never\. RFC 5322 requires both to be escaped as aquoted-pair.Fix
quote_escapedescapes\as well as".\joins the set inspecial_characters_in?, so a bare backslash in an otherwise plain name (Doe\) is quoted instead of going out as an unquoted atom, which is also illegal.Tests
Two cases added to
address_test.rb: a backslash mid-name and a trailing backslash.bundle exec rake teston Ruby 3.4: 161 runs, 304 assertions, 0 failures.rake standardclean.🤖 Generated with Claude Code