Lukasz Lenart created WW-5876:
---------------------------------

             Summary: Ordered escapeMode attribute for tags with escape options
                 Key: WW-5876
                 URL: https://issues.apache.org/jira/browse/WW-5876
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Tags
            Reporter: Lukasz Lenart


Tags with escape options ({{<s:property>}}, {{<s:text>}}, and the {{escape}} 
attribute of {{<s:actionmessage>}}, {{<s:actionerror>}}, {{<s:fielderror>}}) 
apply their escapers in a fixed order: HTML, then JavaScript, then XML, then 
CSV. The order cannot be changed.

The order matters. For a value placed inside JavaScript in an HTML attribute 
({{onclick="..."}}), the correct order is JavaScript escaping first, then HTML 
escaping. The boolean flags cannot express this.

h3. Proposal

Add an {{escapeMode}} attribute holding an ordered, comma-separated chain of 
escapers, applied left to right:

{code}
<button onclick="greet('<s:property value="name" escapeMode="js,html"/>')">
{code}
* Introduce an {{EscapeMode}} enum ({{HTML}}, {{JAVASCRIPT}}, {{XML}}, {{CSV}}) 
and expose the ordered chain on {{EscapeConfig}}, which is passed to the 
pluggable {{TagEscaper}} added in WW-5639.
* When {{escapeMode}} and the boolean flags are both set, {{escapeMode}} wins, 
and in devMode a warning is logged.
* Decide which tags get the attribute, including whether {{escapeHtmlBody}} on 
{{Component}} is in scope.

Builds on WW-5639 (pluggable {{TagEscaper}} and {{EscapeConfig}}).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to