You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Carlos Eduardo Panarello (Jira)" <ji...@apache.org> on 2021/01/02 15:22:00 UTC
[jira] [Updated] (CXF-8391) Regex for addSensitiveElementNames is
replace only the last element
[ https://issues.apache.org/jira/browse/CXF-8391?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Carlos Eduardo Panarello updated CXF-8391:
------------------------------------------
Summary: Regex for addSensitiveElementNames is replace only the last element (was: Regex for addSensitiveElementNames is get one element)
> 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
> Priority: Minor
> Labels: Logging
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Regex Template (MATCH_PATTERN_XML_TEMPLATE) used in MaskSensitiveHelper class 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)