ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r395206 - /ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
Date Wed, 19 Apr 2006 10:50:07 GMT
Author: peterreilly
Date: Wed Apr 19 03:50:02 2006
New Revision: 395206

URL: http://svn.apache.org/viewcvs?rev=395206&view=rev
Log:
escape none URL characters

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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/launch/Locator.java?rev=395206&r1=395205&r2=395206&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 Apr 19 03:50:02 2006
@@ -401,7 +401,20 @@
             String path = location.getPath();
             for (int i = 0; i < extensions.length; ++i) {
                 if (path.toLowerCase().endsWith(extensions[i])) {
-                    urls[0] = location.toURL();
+                    try {
+                        /**
+                         * File.toURL() does not encode characters like #.
+                         * File.toURI() has been introduced in java 1.4, so
+                         * ANT cannot use it (except by reflection)
+                         * FileUtils.toURI() cannot be used by Locator.java
+                         * Implemented this way.
+                         * File.toURL() adds file: and changes '\' to '/' for dos OSes
+                         * encodeUri converts characters like ' ' and '#' to %DD
+                         */
+                        urls[0] = new URL(encodeUri(location.toURL().toString()));
+                    } catch (UnsupportedEncodingException ex) {
+                        throw new MalformedURLException(ex.toString());
+                    }
                     break;
                 }
             }
@@ -420,7 +433,12 @@
             });
         urls = new URL[matches.length];
         for (int i = 0; i < matches.length; ++i) {
-            urls[i] = matches[i].toURL();
+            try {
+                // See comments above.
+                urls[i] = new URL(encodeUri(matches[i].toURL().toString()));
+            } catch (UnsupportedEncodingException ex) {
+                throw new MalformedURLException(ex.toString());
+            }
         }
         return urls;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message