Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9188

Incorrect string replacement order in Camel SNMP

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.14.0, 2.15.3
    • Fix Version/s: 2.16.0, 2.14.4, 2.15.4
    • Component/s: camel-snmp
    • Labels:
      None
    • Estimated Complexity:
      Novice

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              davsclaus Claus Ibsen
              Reporter:
              zlogic Dmitry Zolotukhin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: