Page 1 of 1

Thymleaf double escape

Posted: Sat Feb 21, 2015 7:16 am
by courudavance
Thymeleaf double escape text which are in translations message files (exp : messages_fr.properties) when they are displayed in html code.
To be more clear : (want to display : Connectez-vous à votre compte )
If we have line 64 "login.loginToAccount = "Connectez-vous à votre compte" in file site/src/main/resources/messages_fr.properties
<span th:text="#{login.loginToAccount}"... will produce html code Connectez-vous &amp;agrave; votre compte
so the & in the original text has been replaced by &amp; which will produce a wrong html code.
The text has been escaped twice.
To conclude all html code in translations messages files will be escape again by thymeleaf (th:text=). This is the default for thymleaf escaping all text messages to html code.

This is more informations about my previous topic viewtopic.php?f=15&t=4195 after investigation.

Don't know how to put in translations message files to output good html code for accents.
Hope this will help you to solve my problem.
Thanks.

Re: Thymleaf double escape

Posted: Tue Feb 24, 2015 10:02 pm
by phillipuniverse
Use <span th:utext="#{login.loginToAccount}">

The difference is utext instead of just text. utext will not escape the HTML.