camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAMEL-9188) Incorrect string replacement order in Camel SNMP
Date Sun, 04 Oct 2015 09:24:26 GMT

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

Claus Ibsen updated CAMEL-9188:
-------------------------------
    Fix Version/s: 2.16.1
                   2.17.0
                   2.15.4

> 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
>            Priority: Minor
>             Fix For: 2.15.4, 2.17.0, 2.16.1
>
>
> 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("<", "&lt;").replaceAll(">",
> "&gt;").replaceAll("&", "&amp;").replaceAll("\"",
> "&quot;").replaceAll("'", "&apos;");
>     }
> It replaces “<” with “&lt;” at first, then the “&” is replaced
with
> “&amp;”. This means that a “<” character in the input string will be
> changed to “&lt;”, and then into “&amp;lt;”, which is not the intended
> behavior.
> This could be fixed by applying the “replaceAll("&", "&amp;")”
> transformation first.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message