Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3855

Incorrect character escaping by URIParserUtil

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.2
    • 2.4.4, 2.3.8
    • Tooling
    • Novice

    Description

      Class URIParserUtil. Function escapeChars(String s) produces incorrect result for characters, which utf-8 representation is greater than 1 byte length.
      For example, character "ц" ([-47, -122] in utf-8) is encoded as "%d861", but expected value is "%d186".
      This patch should fix the problem.

      --- URIParserUtil.java	2011-10-11 18:02:59.786548800 +0400
      +++ URIParserUtil.java	2011-10-11 18:03:09.544548800 +0400
      @@ -236,8 +236,9 @@
                           b.setCharAt(x++, '%');
                           for (int y = 0; y < bytes.length; y++) {
                               b.insert(x++, HEX_DIGITS.charAt((bytes[y] & 0xFF) >> 4));
      -                        b.insert(x, HEX_DIGITS.charAt(bytes[y] & 0x0F));
      +                        b.insert(x++, HEX_DIGITS.charAt(bytes[y] & 0x0F));
                           }
      +					x--;
                       } catch (UnsupportedEncodingException e) {
                           //should not happen
                       }
      

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            jenya Jenya Pisarenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: