[ 
https://issues.apache.org/jira/browse/CXF-8391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Colm O hEigeartaigh updated CXF-8391:
-------------------------------------
    Fix Version/s: 3.4.3

> Regex for addSensitiveElementNames is replace only the last element
> -------------------------------------------------------------------
>
>                 Key: CXF-8391
>                 URL: https://issues.apache.org/jira/browse/CXF-8391
>             Project: CXF
>          Issue Type: Bug
>          Components: logging
>    Affects Versions: 3.4.2
>            Reporter: Carlos Eduardo Panarello
>            Assignee: Andrei Shakirin
>            Priority: Minor
>              Labels: Logging
>             Fix For: 3.4.3
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Regex Template (MATCH_PATTERN_XML_TEMPLATE) used in [MaskSensitiveHelper 
> class|https://github.com/apache/cxf/blob/be41158d8c65b227c77d927ace7ca30c7c6dd015/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/MaskSensitiveHelper.java#L30]
>  for replace all ocurrs of element in XML is getting always only one ocurrs 
> when you have a list of elements to replace.
> In this sample of xml
> {noformat}
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>       <soap:Body>
>               <ns1:listResponse xmlns:ns1="http://acme.org/";>
>                       <return xmlns:ns2="http://acme.org/";>
>                               <description>Winter fruit</description>
>                               <name>Apple1</name>
>                       </return>
>                       <return xmlns:ns2="http://acme.org/";>
>                               <description>Tropical fruit</description>
>                               <name>Pineapple1</name>
>                       </return>
>               </ns1:listResponse>
>       </soap:Body>
> </soap:Envelope>
> {noformat}
>  if you need to replace the content of element <description>, the regex used 
> for
> {code:java}
> "(<description.*>)(.*?)(</description>)"
> {code}
>  will started at '<description>Winter fruit' and end at
> 'Tropical fruit</description>' , because of this the replaceAll will replace 
> the last occurs in XML.
> To fix it we have to change the match pattern xml template.
> The correct value for it has to be 
> {code:java}
>   private static final String MATCH_PATTERN_XML_TEMPLATE = 
> "(<-ELEMENT_NAME-*.?>)(.*?)(</-ELEMENT_NAME->)";
> {code}
> not
> {code:java}
>   private static final String MATCH_PATTERN_XML_TEMPLATE = 
> "(<-ELEMENT_NAME-.*>)(.*?)(</-ELEMENT_NAME->)";
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to