[ 
https://issues.apache.org/jira/browse/WW-5639?focusedWorklogId=1057297&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1057297
 ]

ASF GitHub Bot logged work on WW-5639:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Nov/26 17:43
            Start Date: 26/Nov/26 17:43
    Worklog Time Spent: 10m 
      Work Description: sonarqubecloud[bot] commented on PR #2176:
URL: https://github.com/apache/struts/pull/2176#issuecomment-7199529760

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=2176) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [1 New 
issue](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2176&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_struts&pullRequest=2176&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_struts&pullRequest=2176&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [90.1% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2176&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=2176&metric=new_duplicated_lines_density&view=list)
  
     
   <!

Issue Time Tracking
-------------------

    Worklog Id:     (was: 1057297)
    Time Spent: 0.5h  (was: 20m)

> <s:property> escape options should be mutually exclusive
> --------------------------------------------------------
>
>                 Key: WW-5639
>                 URL: https://issues.apache.org/jira/browse/WW-5639
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Tags
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.6.0
>
>         Attachments: ww-5639-struts.patch
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The {{<s:property>}} tag exposes four boolean escape attributes — 
> {{escapeHtml}}
> (default {{true}}), {{escapeJavaScript}}, {{escapeXml}} and {{escapeCsv}} 
> (default
> {{false}}). {{Property.prepare()}} applies them *cumulatively*, chaining one
> escaper after another. Chaining escapers that target different output contexts
> produces corrupt output:
> * {{escapeHtml=false escapeJavaScript=true}} on {{<b></b>}} yields 
> {{<b><\/b>}},
>   because {{escapeEcmaScript}} escapes {{/}} as {{\/}}. The closing tag is 
> broken
>   and the rendered layout is damaged. Allowing HTML markup ({{<b>}}, 
> {{<strong>}},
>   {{<em>}}) while also JavaScript-escaping is impossible — the two contexts
>   conflict by nature.
> * Leaving {{escapeHtml=true}} (the default) while also setting 
> {{escapeXml=true}}
>   or {{escapeCsv=true}} double-escapes entities ({{escapeHtml4}} turns {{&}} 
> into
>   {{&amp;}}, then {{escapeXml10}} escapes the {{&}} again).
> h3. Note on security
> {{escapeJavaScript}} ({{escapeEcmaScript}}) escapes only {{' " \ /}} and 
> control
> characters; it does *not* escape {{<}}, {{>}} or {{&}}, so it is not an
> HTML-safety mechanism. The real exposure is that {{escapeHtml=false}} emits 
> raw,
> unescaped HTML — an XSS risk unless the value is fully trusted.
> h3. Proposed fix
> Make the four escape options mutually exclusive. Apply exactly one escaper,
> selected by first-match precedence:
> {noformat}
> escapeHtml -> escapeJavaScript -> escapeXml -> escapeCsv
> {noformat}
> HTML has the highest precedence. Since {{escapeHtml}} defaults to {{true}}, 
> the
> default behavior (HTML escaping only) is unchanged, and the established 
> pattern of
> "set {{escapeHtml=false}} plus the one escaper you want" is preserved. The 
> only
> outputs that change are configurations that were already producing corrupt
> double-escaped results.
> h3. Additionally
> * When {{devMode}} is enabled and more than one escape flag is set, log a 
> warning
>   naming which escaper was applied and noting the options are mutually 
> exclusive.
> * Update the {{escapeHtml}} / {{escapeJavaScript}} {{@StrutsTagAttribute}}
>   descriptions and the class JavaDoc: {{escapeHtml=false}} emits raw HTML (XSS
>   risk unless the value is trusted); {{escapeJavaScript}} targets a JS
>   string-literal context, not HTML, and escapes {{/}} as {{\/}} so it cannot
>   coexist with surviving HTML markup.
> This is a behavior change and should ship in *7.3.x* (minor). The public docs 
> page
> at [https://struts.apache.org/tag-developers/property-tag] is updated 
> separately
> in the {{struts-site}} repo.



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

Reply via email to