You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jenya Pisarenko (Created) (JIRA)" <ji...@apache.org> on 2011/10/11 16:17:12 UTC

[jira] [Created] (CXF-3855) Incorrect character escaping by URIParserUtil

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


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
                 }

--
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

       

[jira] [Commented] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Daniel Kulp (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13131640#comment-13131640 ] 

Daniel Kulp commented on CXF-3855:
----------------------------------

According to:

http://en.wikipedia.org/wiki/Percent-encoding

the percent encoding is in octets and thus it should be %d8%61.


                
> 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

       

[jira] [Updated] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Jenya Pisarenko (Updated) (JIRA)" <ji...@apache.org>.
     [ 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.

[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]

  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.

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

    
> 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.
> [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]

--
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

       

[jira] [Updated] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Daniel Kulp (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp updated CXF-3855:
-----------------------------

    Fix Version/s: 2.3.8
    
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.3.8, 2.4.4
>
>
> 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

       

[jira] [Commented] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Daniel Kulp (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13131748#comment-13131748 ] 

Daniel Kulp commented on CXF-3855:
----------------------------------


Right. %d1%86    I actually rewrote the whole method to simplify it which fixes that issue and the each byte needs it issue. 

Fixed on trunk and 2.4.x now.
                
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.4.4
>
>
> 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

       

[jira] [Closed] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Freeman Fang (Closed) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Freeman Fang closed CXF-3855.
-----------------------------

    
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.3.8, 2.4.4
>
>
> 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

       

[jira] [Commented] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Daniel Kulp (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13131637#comment-13131637 ] 

Daniel Kulp commented on CXF-3855:
----------------------------------


Actually, I think it should be escaped to %d8%61 to go into a URI?  Right?

If I do:
{code}
      String orig = new String(new byte[] {-47, -122}, "UTF-8");
      orig = "/foo" + orig + ".txt";
      String s = URIParserUtil.escapeChars(orig);
      assertEquals(orig, new File(new URI("file:" + s)).
{code}

it fails as the URI doesn't decode properly with the old code or your code.  If I use %d8%61, it passes.   Does anyone agree/disagree with that?



                
> 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

       

[jira] [Resolved] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Daniel Kulp (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Daniel Kulp resolved CXF-3855.
------------------------------

       Resolution: Fixed
    Fix Version/s: 2.4.4
         Assignee: Daniel Kulp
    
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.4.4
>
>
> 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

       

[jira] [Commented] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Jenya Pisarenko (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13131741#comment-13131741 ] 

Jenya Pisarenko commented on CXF-3855:
--------------------------------------

Daniel, you're right. Each encoded byte should be escaped with the percent sign. But it's not enough.
The sequence of hex digits in the original method implementation is not correct.
We have: [d 8 6 1], but correct is [d 1 8 6].

So, result for the example above should be %d1%86.

                
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.4.4
>
>
> 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

       

[jira] [Commented] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Aki Yoshida (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-3855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13136963#comment-13136963 ] 

Aki Yoshida commented on CXF-3855:
----------------------------------

The unit test for this patch seems to fail on windows because of the windows specific directory prefix automatically added by URI.getAbsolutePath() in

        assertEquals(orig, new File(new URI("file:" + s)).getAbsolutePath());

resulting in:

Running org.apache.cxf.tools.util.URIParserUtilTest
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec <<< FAILURE!
testCXF3855(org.apache.cxf.tools.util.URIParserUtilTest)  Time elapsed: 0.001 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[/]foo?.txt> but was:<[C:\]foo?.txt>

We should change this assertion line to:
        assertEquals(orig, URLDecoder.decode(s, "UTF-8"));


                
> 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
>            Assignee: Daniel Kulp
>            Priority: Minor
>              Labels: parse, utf-8, util
>             Fix For: 2.3.8, 2.4.4
>
>
> 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

       

[jira] [Updated] (CXF-3855) Incorrect character escaping by URIParserUtil

Posted by "Jenya Pisarenko (Updated) (JIRA)" <ji...@apache.org>.
     [ 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