adamsaghy commented on PR #6672:
URL: https://github.com/apache/fineract/pull/6672#issuecomment-6213347576

   @rymghosn Please review my concern around accents:
   
   **HTML emails corrupt accented letters and symbols**
   
   Where: GmailBackedPlatformEmailService.java, the new HTML branch, on the 
line new MimeMessageHelper(mimeMessage).
   
   MimeMessageHelper is created without an encoding, so setText(body, true) 
sets the content type to just text/html, with no charset. When the message is 
built, Jakarta Mail labels it charset=UTF-8, but it writes the body as if it 
were ASCII. The header and the bytes don’t match.
   
   I checked this outside Fineract, using the same library versions as develop 
(Spring 7.0.9, com.sun.mail:jakarta.mail:2.0.2). I sent the body <p>Dear José 
Müller, … – ₹100</p> through the PR’s HTML path:
   ```
   Content-Type: text/html; charset=UTF-8
   Content-Transfer-Encoding: quoted-printable
   
   <p>Dear Jos=E9 M=FCller, click <a href=3D"x">here</a> ? ?100</p>
   ```
   When I read the message back, it came out as Jos� M�ller … ? ?100. The – and 
₹ were replaced with ?, and é and ü were written in the wrong encoding.
   
   The same body sent through the existing plain-text path comes back 
unchanged. So switching an email to HTML would make it worse for any 
non-English recipient name, organisation name or currency symbol, and 
Fineract’s emails contain all three.
   
   Fix: pass the encoding explicitly:
   
   `MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, 
StandardCharsets.UTF_8.name());`
   
   The new sendDefinedEmailSendsHtmlWhenRequested test only uses an ASCII body, 
which is why it passes. Adding a non-ASCII character to it (e.g. é) would catch 
this.


-- 
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