cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jenya Pisarenko (Updated) (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-3855) Incorrect character escaping by URIParserUtil
Date Tue, 11 Oct 2011 14:19:12 GMT

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

Jenya Pisarenko updated CXF-3855:
---------------------------------

    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.

{noformat}
--- 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
                 }
{noformat}

  was:
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.

[code]
--- 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
                 }
[/code]

    
> Incorrect character escaping by URIParserUtil
> ---------------------------------------------
>
>                 Key: CXF-3855
>                 URL: https://issues.apache.org/jira/browse/CXF-3855
>             Project: CXF
>          Issue Type: Bug
>          Components: Tooling
>    Affects Versions: 2.4.2
>            Reporter: Jenya Pisarenko
>            Priority: Minor
>              Labels: parse, utf-8, util
>
> 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.
> {noformat}
> --- 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
>                  }
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message