Encode non-ASCII SMTP attachment file names according to RFC 2231 - #6757
Open
ashrafiucse wants to merge 1 commit into
Open
Encode non-ASCII SMTP attachment file names according to RFC 2231#6757ashrafiucse wants to merge 1 commit into
ashrafiucse wants to merge 1 commit into
Conversation
The SMTP Sampler used javax.mail 1.5.0-b01, which mangles attachment file names that contain non-ASCII characters (for example a file named "текст.txt" was sent as "B5:AB.txt"), so recipients could not see the original file name. Update javax.mail to 1.6.2 (com.sun.mail:javax.mail), which encodes non-ASCII file name parameters according to RFC 2231. The javax.mail namespace is unchanged, so no code changes are needed. Closes apache#6652
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.
Description
Upgrade
javax.mailfrom the 2013 betajavax.mail:mail:1.5.0-b01tocom.sun.mail:javax.mail:1.6.2, so that attachment file names containing non-ASCII characters are encoded according to RFC 2231.The
javax.mail.*namespace is unchanged, so no code changes are required. The dependency verification metadata already trusts thecom.sun.mailgroup (PGP key4F7E32D440EF90A83011A8FC6425559C47CC79C4), so noverification-metadata.xmlchanges were needed.Motivation and Context
Fixes #6652
The SMTP Sampler mangles attachment file names that contain non-ASCII characters. Sending an attachment named
текст.txtproduces:so recipients see garbage instead of the original file name.
Root cause:
SendMailCommandbuilds attachments withMimeBodyPart.setFileName(String). The oldjavax.mail:mail:1.5.0-b01does not encode non-ASCII file name parameters according to RFC 2231.As suggested by @FSchumacher on the issue, upgrading to 1.6.2 fixes the encoding. With this change the same attachment is now sent as:
How Has This Been Tested?
SendMailCommandTest:testNonAsciiAttachmentFileNameIsEncodedPerRfc2231: builds a message (viaprepareMessage(), no SMTP server needed) with an attachment namedтекст.txtand asserts the raw message containsfilename*=UTF-8''%D1%82%D0%B5%D0%BA%D1%81%D1%82.txtand no mangled nametestAsciiAttachmentFileNameIsNotEncoded: asserts pure ASCII names are still emitted as plainfilename=attachment.txt(no RFC 2231 encoding):src:protocol:mail:test(4 tests) and:src:components:test(549 tests,MailReaderSamplershares the dependency) suites pass./gradlew classes stylepassesScreenshots (if appropriate):
Not applicable (raw SMTP headers shown above).
Types of changes
Checklist:
xdocs/changes.xml)