[
https://issues.apache.org/jira/browse/WW-4742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16295501#comment-16295501
]
Augusto Souza edited comment on WW-4742 at 12/18/17 7:32 PM:
-------------------------------------------------------------
[~lukaszlenart], I'm working in the same project/problem related by
[~mtsbarbosa].
I'm using the 2.5.10.1 version. The code works like this:
{code:java}
msg = defaultMessage; // Test xpto' and xptó
msg = StringEscapeUtils.escapeEcmaScript(msg); // Test xpto\' and xpt\u00F3
msg = StringEscapeUtils.escapeHtml4(msg); // Test xpto\' and xpt\u00F3
{code}
Note that in the above example escapeHtml4 doesn't even make sense.
My proposed solution to avoid characters problems is, first use the escapeHtml4
method and then use escapeEcmaScript method:
{code:java}
msg = defaultMessage; // Teste xpto' and xptó
msg = StringEscapeUtils.escapeHtml4(msg); // Teste xpto' and xptó
msg = StringEscapeUtils.escapeEcmaScript(msg); // Teste xpto\' and xptó
{code}
I hope you consider this solution, thanks
was (Author: augustosouza):
[~lukaszlenart], I'm working in the same project/problem related by
[~mtsbarbosa].
Its enough if change the scape order, first escapeHtml4, and after
escapeEcmaScript.
In the version 2.5.10.1 the code works like this:
{code:java}
msg = defaultMessage; // Test xpto' and xptó
msg = StringEscapeUtils.escapeEcmaScript(msg); // Test xpto\' and xpt\u00F3
msg = StringEscapeUtils.escapeHtml4(msg); // Test xpto\' and xpt\u00F3
{code}
Note that in the above example escapeHtml4 doesn't even make sense.
My proposed solution to avoid special characters problems is:
{code:java}
msg = defaultMessage; // Teste xpto' and xptó
msg = StringEscapeUtils.escapeHtml4(msg); // Teste xpto' and xptó
msg = StringEscapeUtils.escapeEcmaScript(msg); // Teste xpto\' and xptó
{code}
I hope you consider this solution, thanks
> Problem with escape when the key from getText has no value
> ----------------------------------------------------------
>
> Key: WW-4742
> URL: https://issues.apache.org/jira/browse/WW-4742
> Project: Struts 2
> Issue Type: Bug
> Components: Core Tags
> Affects Versions: 2.5.8, 2.5.10
> Reporter: Mateus Carvalho
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 2.6
>
>
> When using an encoding like ISO-8859-1 and having the following situation:
> {code:title=message.ftl|borderStyle=solid}
> ...
> <@s.text name="Obrigatório - not mapped word in any dictionary" />
> ...
> {code}
> We have the following output after update 2.5.8:
> {code}
> Obrigat\u00F3rio - not mapped word in any dictionary
> {code}
> After careful look at the source code and issues from the 2.5.8 I found the
> problem happens just in one added line on WW-4712, the following part of the
> code:
> {code:title=TextProviderHelper.java|borderStyle=solid}
> ...
> public static String getText(String key, String defaultMessage, List<Object>
> args, ValueStack stack, boolean searchStack) {
> ...
> //This escape causes the problem
> msg = StringEscapeUtils.escapeEcmaScript(msg);
> ...
> }
> ...
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)