marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.37k stars 644 forks source link

Encoding problem when using marko in mail subject #1532

Closed marvinfretly closed 4 years ago

marvinfretly commented 4 years ago

Hello,

I'm creating mails using email-templates and marko as a template engine. So I've to create a file named subject.marko. Everything is going great but when I there is accent in my subject.marko, it got encoding problem and it look like that: Subject: =?UTF-8?Q?Demande_d=27une_revued=27activit=C3=A9?= When the file look like: -- Demande d'une revue d'activité

How is it possible to get the good encoding for my subject with accent? I tried to add 'utf-8' to message.encoding but nothing happened. (this is nodemailer related) Also removed subject.marko and made a new one to make sure there no encoding error on my file.

DylanPiercey commented 4 years ago

@marvinfretly could you share a snippet of Marko code and also the output you'd expect vs are getting?

marvinfretly commented 4 years ago

subject.marko: -- Email de test ! C'est génial ça (test accents)

Output: =?UTF-8?Q?Email_detest!_C=27estg=C3=A9nial?= =?UTF-8?Q?=C3=A7a_=28test_accents=29?=

Expected: Email de test ! C'est génial ça (test accents)

DylanPiercey commented 4 years ago

Looking at that code in the try online it doesn't look like anything special is happening here (https://markojs.com/try-online/?file=%2Fgist%2Fissue.marko&gist=d0769a752ba2c835f66aaf1d64c2c543). Is there another place in your app where the encoding may be happening?

marvinfretly commented 4 years ago

Yes it's the same for me if the same file is used for the mail body. But when I try to use this file for the mail subject it look like it add extra encoding, because I think a mail subject can't use utf8

DylanPiercey commented 4 years ago

Then it doesn't sound like this issue has anything specifically to do with Marko?

marvinfretly commented 4 years ago

I think the problem is that Marko is forcing utf8. Is there a way to disable encoding inside template?

marvinfretly commented 4 years ago

I found the problem and it's not marko related. Thank you for your time