Hi,
I speak in french and then my website is translate in french.
I use user mail workflow to send email to my user (Creation account, ...). With swiftmailer plugin I have a problem because you define in "massageMessageBody" that the text need to be an instance of MarkupInterface to avoid going through the escape function.
User mail define by drupal is simply a text plain and then you pass by HTML::escape. It's a problem because you have single quote encoding. And then when you recieve an email after user creation, I have single quote replace by &...;
I have define plain text on my configuration. Then I think it's not a right choice to use escape function on a body that don't need to do it.
I have try do create a patch. I had test to define if body (not safe) contains html or not. Because if the text is send as plain text and don't have html in his body. You don't need to escape the body part.
PS: Sry for my english
Comment | File | Size | Author |
---|---|---|---|
#7 | 2937293-7.patch | 988 bytes | webflo |
| |||
#4 | swiftmailer-text_plain_without_escape-2937293-4-8.x-1.x.patch | 672 bytes | id.rem.dev |
| |||
#4 | interdiff.txt | 609 bytes | id.rem.dev |
#2 | swiftmailer-text_plain_without_escape-2937293-2-8.x-1.x.patch | 670 bytes | isaacrc |
Text_plain_without_escape.patch | 924 bytes | noita | |
Comments
Comment #2
isaacrc CreditAttribution: isaacrc commentedUpdate for the latest version.
Comment #3
noita CreditAttribution: noita as a volunteer commentedSomeone ?
Comment #4
id.rem.dev CreditAttribution: id.rem.dev at Internetdevels, Drupal Ukraine Community commentedImproved patch a little bit.
See http://php.net/manual/en/language.operators.comparison.php#example-104
Please check it.
Comment #5
noita CreditAttribution: noita as a volunteer commentedNot necessary but if you prefer...
Comment #6
benoit.condaminet CreditAttribution: benoit.condaminet at Niji commentedHello,
I think if format is not html, we should not HTML::escape message body at all (even if <> are found). Because in dev for exemple, we could have twig template debug markup added to the mail. Plain text version of mail should not be rendered by mail client (or it's a big issue for them).
Comment #7
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedHi, could you try this patch? It uses MailFormatHelper::htmlToText. This is same them logic as in Drupals default mail plugin.
Comment #8
TwoDThis looks good and helped us fix issues both with Core's plaintext emails and our custom emails sent as plain text.
Comment #10
joep.hendrix CreditAttribution: joep.hendrix at CompuBase Internet Solutions commented#7 works for me.
Thank you.
Comment #12
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedThanks for testing this patch.
Comment #15
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedI think this patch might cause a significant problem. It added a call to
MailFormatHelper::htmlToText()
that runs even if the target format is HTML. I believe this will particularly affect people who have put HTML markup into their user account messages - a scenario that worked prior to this patch.I have an alternative plan that I believe works for everyone all the time. Hence in the new 2.x branch I propose we back this commit out, and I'm setting needs work as the closest status I can see to try to indicate this.
The comments here include some prominent members of the Drupal community so please drop over to #3122389: Bugs with format conversion and tell me what you think.
Comment #16
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedSorry that wasn't the correct description of the problem.
Code before this patch
Html::escape()
is correct if output format is HTML.Code after this patch
MailFormatHelper::htmlToText()()
is correct if output format is plain text.What we need is an if statement that chooses between the two. I'll just close this again and we can fix it in #3122389: Bugs with format conversion.