Thymleaf double escape
Posted: Sat Feb 21, 2015 7:16 am
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 &agrave; votre compte
so the & in the original text has been replaced by & 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.
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 &agrave; votre compte
so the & in the original text has been replaced by & 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.