kamax-matrix / mxisd

Federated Matrix Identity Server
GNU Affero General Public License v3.0
223 stars 115 forks source link

Invitation subject is not sent correctly with non-standard characters (1.3.1) #137

Closed valentinab25 closed 5 years ago

valentinab25 commented 5 years ago

Hello,

We are using our template (medium.email.generators.template.generic.matrixId ) for sending notifications with the following subject:

Subject: %SENDER_NAME_OR_ID% invites you to chat %ROOM_NAME%

In 1.3.1, the subject is not sent correctly when there are any special characters in the name - example "Valentina Bălan invites you to chat test" instead of "Valentina Bălan invites you to chat test". It used to work in the previous versions (for example 1.2.0) . The same characters are sent correctly in the email body.

Is there something I need to set in the template to allow special characters in subjects ? I did not find any reference for subject character set, only for the body ( which works ok).

Thank you

maxidorius commented 5 years ago

I had to do some research and this is what I found: there are two RFCs that deal with this:

It seems like 2047 is the one used by email clients. I have sent a test email to myself and this is the Subject header produced:

Subject: =?UTF-8?Q?Valentina_B=c4=83lan_invites_you_to_chat_test?=

which shows as

Valentina Bălan invites you to chat test

I think it was never meant to work and it was just a lucky set of classes available that did in previous releases. This is definitely the valid way of doing it.

valentinab25 commented 5 years ago

Thank you for the quick response. Is it possible for you to use this encoding when you are setting the email subject in code? The problem is that the characters are in %SENDER_NAME_OR_ID%, so there is no way for me to write the subject in the correct format directly in the template.

maxidorius commented 5 years ago

Oh, you're right, my bad. I'll fix it this week yes!

maxidorius commented 5 years ago

@valentinab25 After further investigation, the fix is not as easy as I thought it would be, but definitely doable. It will take a few more days. I'll ping you with a docker build when I have something!

maxidorius commented 5 years ago

@valentinab25 In case you haven't already, can you try with the latest build please ? kamax/mxisd:1.4.2-7-gce7f900