ashrafiucse opened a new pull request, #6757:
URL: https://github.com/apache/jmeter/pull/6757

   ## Description
   Upgrade `javax.mail` from the 2013 beta `javax.mail:mail:1.5.0-b01` to 
`com.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 the `com.sun.mail` group 
(PGP key `4F7E32D440EF90A83011A8FC6425559C47CC79C4`), so no 
`verification-metadata.xml` changes were needed.
   
   ## Motivation and Context
   Fixes #6652
   
   The SMTP Sampler mangles attachment file names that contain non-ASCII 
characters. Sending an attachment named `текст.txt` produces:
   
   ```
   Content-Type: text/plain; charset=us-ascii;
           name="B5:AB-attachment....txt"
   Content-Disposition: attachment;
           filename="B5:AB-attachment....txt"
   ```
   
   so recipients see garbage instead of the original file name.
   
   **Root cause:** `SendMailCommand` builds attachments with 
`MimeBodyPart.setFileName(String)`. The old `javax.mail:mail:1.5.0-b01` does 
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:
   
   ```
   Content-Type: text/plain; charset=us-ascii;
           name*=UTF-8''%D1%82%D0%B5%D0%BA%D1%81%D1%82.txt
   Content-Disposition: attachment;
           filename*=UTF-8''%D1%82%D0%B5%D0%BA%D1%81%D1%82.txt
   ```
   
   ## How Has This Been Tested?
   - New `SendMailCommandTest`:
     - `testNonAsciiAttachmentFileNameIsEncodedPerRfc2231`: builds a message 
(via `prepareMessage()`, no SMTP server needed) with an attachment named 
`текст.txt` and asserts the raw message contains 
`filename*=UTF-8''%D1%82%D0%B5%D0%BA%D1%81%D1%82.txt` and no mangled name
     - `testAsciiAttachmentFileNameIsNotEncoded`: asserts pure ASCII names are 
still emitted as plain `filename=attachment.txt` (no RFC 2231 encoding)
   - Full `:src:protocol:mail:test` (4 tests) and `:src:components:test` (549 
tests, `MailReaderSampler` shares the dependency) suites pass
   - `./gradlew classes style` passes
   - Verified the original repro end-to-end against a locally built distribution
   
   ## Screenshots (if appropriate):
   Not applicable (raw SMTP headers shown above).
   
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   
   ## Checklist:
   - [x] My code follows the [code style][style-guide] of this project.
   - [x] I have updated the documentation accordingly. (release notes entry 
added to `xdocs/changes.xml`)
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to