ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgl...@apache.org
Subject svn commit: r1055487 - in /ant/core/trunk/src: main/org/apache/tools/ant/launch/Locator.java tests/junit/org/apache/tools/ant/launch/LocatorTest.java
Date Wed, 05 Jan 2011 15:18:00 GMT
Author: jglick
Date: Wed Jan  5 15:17:59 2011
New Revision: 1055487

URL: http://svn.apache.org/viewvc?rev=1055487&view=rev
Log:
#50543: decodeUri broken for non-ASCII chars in input.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java?rev=1055487&r1=1055486&r2=1055487&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java Wed Jan  5 15:17:59 2011
@@ -312,8 +312,11 @@ public final class Locator {
                         sb.write((char) ((i1 << NIBBLE) + i2));
                     }
                 }
-            } else {
+            } else if (c >= 0x0000 && c < 0x0080) {
                 sb.write(c);
+            } else { // #50543
+                byte[] bytes = String.valueOf(c).getBytes(URI_ENCODING);
+                sb.write(bytes, 0, bytes.length);
             }
         }
         return sb.toString(URI_ENCODING);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java?rev=1055487&r1=1055486&r2=1055487&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java Wed Jan  5
15:17:59 2011
@@ -172,6 +172,10 @@ public class LocatorTest extends TestCas
         char umlauted = result.charAt(1);
         assertEquals("expected 0xf6 (\u00f6), but got " + Integer.toHexString(umlauted) +
" '"
                 + umlauted + "'", 0xf6, umlauted);
+        assertEquals("file:/tmp/a%C3%A7a%C3%AD%20berry", Locator.encodeURI("file:/tmp/a\u00E7a\u00ED
berry"));
+        assertEquals("file:/tmp/a\u00E7a\u00ED berry", Locator.decodeUri("file:/tmp/a%C3%A7a%C3%AD%20berry"));
+        assertEquals("file:/tmp/a\u00E7a\u00ED berry", Locator.decodeUri("file:/tmp/a\u00E7a\u00ED%20berry"));
// #50543
+        assertEquals("file:/tmp/hezky \u010Desky", Locator.decodeUri("file:/tmp/hezky%20\u010Desky"));
// non-ISO-8859-1 variant
     }
 
     public void testOddLowAsciiURI() throws Exception {



Mime
View raw message