Skip to content

Special characters in store name converted to numerical character references in email subject #8094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mattcoz opened this issue Jan 10, 2017 · 20 comments
Labels
bug report Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@mattcoz
Copy link

mattcoz commented Jan 10, 2017

If your store name has a special character in it, such as an apostrophe, it will be converted to a numerical character reference in any email subject. For example:

Store name: Bob's Burgers
Reset password email subject: Reset your Bob's Burgers password

I've tried sending the email directly with php and with Zend_Mail without issues, so it must be somewhere in Magento's email template handling.

@veloraven
Copy link
Contributor

@mattcoz thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.
Please, also identify which version of Magento you are running.

@mattcoz
Copy link
Author

mattcoz commented Jan 11, 2017

Steps to reproduce:

  1. Set store name to "Bob's Burgers"
  2. Request a password reset

Expected result:

Subject should be "Reset your Bob's Burgers password"

Actual result:

Subject is "Reset your Bob's Burgers password"

@veloraven
Copy link
Contributor

@mattcoz thank you for update.
I have created internal ticket for this issue: MAGETWO-63154

@veloraven veloraven added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report develop and removed Progress: needs update labels Jan 13, 2017
@bat553
Copy link

bat553 commented Jan 13, 2017

@veloraven Is there a way to track this ticket ?

@rudik99
Copy link

rudik99 commented Jan 31, 2017

Im not sure if you want me to raise another issue, but this happens all the way through the emails.

So If a customer submits via contact form the same thing happens - apostrophe is converted like the example above.

@korostii
Copy link
Contributor

korostii commented Feb 23, 2017

I can confirm that this issue appears in other email as well. For example, when you share a wishlist via email, the subject according to this line and then in your inbox it is also shown with this weird ' inside.

@korostii
Copy link
Contributor

In particular case of the wishlist, the issues seems to be coming out of this little quirk which doesn't seem to care whether the directive is invoked inside subject or body of the email.

To anyone struggling, this is quite an easy workaround: in a given template just add that |raw part at the end of the directive, like in the following:
<!--@subject {{trans "Take a look at %customer_name's Wish List" customer_name=$customerName|raw}} @-->

@hardyjohnson
Copy link

Probably related #6597 and MAGETWO-58663 which is referenced in that issue.

@mattcoz
Copy link
Author

mattcoz commented Apr 10, 2017

@korostii Thanks for the workaround, unfortunately it's a pain to have to override every single email template file to fix this. Instead I created a simple plugin to reverse the encoding.

public function afterGetSubject(\Magento\Email\Model\Template $subject, $result)
{
	return htmlspecialchars_decode((string)$result, ENT_QUOTES);
}

@PieterCappelle
Copy link
Contributor

PieterCappelle commented May 2, 2017

Quick fix is in di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Email\Model\Template">
        <plugin name="mail_subject" type="VENDOR\MODULE\Plugin\Template" sortOrder="100" />
    </type>
</config>

In Template.php

namespace VENDOR\MODULE\Plugin;

class Template
{
    public function afterGetSubject(
        \Magento\Email\Model\Template $subject,
        $result
    ) {
        return htmlspecialchars_decode((string)$result, ENT_QUOTES);
    }
}

magento-team pushed a commit that referenced this issue May 26, 2017
Fixed issues:
- MAGETWO-63054 [Catalog] MSRP field is not displayed for bundle products with fixed price
- MAGETWO-63154 Special characters in store name converted to numerical character references in email subject #8094
- MAGETWO-60692 [Github]Bundle product order - create invoice via REST API #6988
- MAGETWO-60514 The exchange rate in order is duplicated
- MAGETWO-64967 Export locks admin panel
- MAGETWO-67529 [Catalog] Configurable product visible on frontend when all child products are disabled
- MAGETWO-67574 [Catalog] Denied category is visible on SF
- MAGETWO-60628 [GITHUB] Refund report does not show right date #5317
- MAGETWO-69111 Customer custom address attributes lost after changing contact information and password
- MAGETWO-67745 The "Catalog Search indexer process unknown error" appears after reindex
- MAGETWO-64885 Wrong cookies set for store views with multidomain
@veloraven
Copy link
Contributor

This issue was fixed in develop branch.
Closed.

@korostii
Copy link
Contributor

Hi @veloraven, having a fix on develop isn't the same as resolving the issue.

Are there any plans to backport this issue on Magento side?
If not, please reopen the issue and mark it as "up for grabs" so that people would know it is okay to create a pull request targeting 2.1-develop in order to help with the backporting process.

@ziiljuks
Copy link

ziiljuks commented Aug 3, 2017

return htmlspecialchars_decode((string)$result, ENT_QUOTES);

This didn't work for me but this did:

return mb_encode_mimeheader((string)$result,"UTF-8");

@kanduvisla
Copy link
Contributor

In what develop branch is this fixed then? Because it still persists in 2.1.8.

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 14, 2017
@korostii
Copy link
Contributor

@magento-engcom-team The issue is still present, please reopen (see the comment above).

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Nov 8, 2017

@korostii this issue was fixed in 2.2.0. You can find related commits there:
https://github.com/magento/magento2/search?q=MAGETWO-63154&type=Commits&utf8=%E2%9C%93

@magento-engcom-team looks like it wasn't fixed in 2.1.x

@ihor-sviziev ihor-sviziev added Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Nov 10, 2017
@KM-HM
Copy link

KM-HM commented May 31, 2018

This issue is still in in 2.2.4

Preconditions

  1. Magento Version 2.2.4
  2. PHP 7.0.30-0ubuntu0.16.04.1

Steps to reproduce

  1. Create a e-mail template containing a "ü" (üäö german stuff) in the subject
  2. Create an Order to get the E-mail
  3. View the email in outlook

Expected result

  1. E-mail subject should display the "ü" like it was authored

Actual result

  1. E-mail subject shows "?" question mark in the same position as the "ü" should be

Also the System does not retrieve the subject line when opening the email template.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented May 31, 2018

Hi @kemexyz ,
It looks very similar, but it's different. Could you report it as separate issue?

@KM-HM
Copy link

KM-HM commented May 31, 2018

Hey @ihor-sviziev ,

sure, not quite sure if got 2 issues mixed up here ... sorry!

@bewithmanoj
Copy link

Quick fix is in di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Email\Model\Template">
        <plugin name="mail_subject" type="VENDOR\MODULE\Plugin\Template" sortOrder="100" />
    </type>
</config>

In Template.php

namespace VENDOR\MODULE\Plugin;

class Template
{
    public function afterGetSubject(
        \Magento\Email\Model\Template $subject,
        $result
    ) {
        return htmlspecialchars_decode((string)$result, ENT_QUOTES);
    }
}

Quick fix is in di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Email\Model\Template">
        <plugin name="mail_subject" type="VENDOR\MODULE\Plugin\Template" sortOrder="100" />
    </type>
</config>

In Template.php

namespace VENDOR\MODULE\Plugin;

class Template
{
    public function afterGetSubject(
        \Magento\Email\Model\Template $subject,
        $result
    ) {
        return htmlspecialchars_decode((string)$result, ENT_QUOTES);
    }
}

Where i can put the code can you help i am new in magento

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.1.x The issue has been fixed in 2.1 release line Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests