You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (JIRA)" <ji...@apache.org> on 2015/10/04 11:28:26 UTC
[jira] [Resolved] (CAMEL-9188) Incorrect string replacement order
in Camel SNMP
[ https://issues.apache.org/jira/browse/CAMEL-9188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-9188.
--------------------------------
Resolution: Fixed
Fix Version/s: (was: 2.16.1)
(was: 2.17.0)
2.14.4
2.16.0
> Incorrect string replacement order in Camel SNMP
> ------------------------------------------------
>
> Key: CAMEL-9188
> URL: https://issues.apache.org/jira/browse/CAMEL-9188
> Project: Camel
> Issue Type: Bug
> Components: camel-snmp
> Affects Versions: 2.14.0, 2.15.3
> Reporter: Dmitry Zolotukhin
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 2.16.0, 2.14.4, 2.15.4
>
>
> In Camel SNMP, the org.apache.camel.component.snmp.SnmpConverters
> class has a static “getXmlSafeString” method which escapes unsafe
> characters by replacing them. However, the order of applying
> replacements is not correct:
> private static String getXmlSafeString(String string) {
> return string.replaceAll("<", "<").replaceAll(">",
> ">").replaceAll("&", "&").replaceAll("\"",
> """).replaceAll("'", "'");
> }
> It replaces “<” with “<” at first, then the “&” is replaced with
> “&”. This means that a “<” character in the input string will be
> changed to “<”, and then into “&lt;”, which is not the intended
> behavior.
> This could be fixed by applying the “replaceAll("&", "&")”
> transformation first.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)