[jboss-svn-commits] JBoss Common SVN: r2886 - common-core/trunk/src/main/java/org/jboss/util.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 23 13:09:45 EDT 2008
Author: adrian at jboss.org
Date: 2008-07-23 13:09:45 -0400 (Wed, 23 Jul 2008)
New Revision: 2886
Modified:
common-core/trunk/src/main/java/org/jboss/util/Strings.java
Log:
[JBCOMMON-60] - Correctly decode URI/Ls in property editors
Modified: common-core/trunk/src/main/java/org/jboss/util/Strings.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/util/Strings.java 2008-07-23 17:09:02 UTC (rev 2885)
+++ common-core/trunk/src/main/java/org/jboss/util/Strings.java 2008-07-23 17:09:45 UTC (rev 2886)
@@ -23,10 +23,12 @@
import java.io.File;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.List;
@@ -845,7 +847,7 @@
throws IOException
{
// make sure the file is absolute & canonical file url
- File file = new File(filespec);
+ File file = new File(decode(filespec));
// if we have a prefix and the file is not abs then prepend
if (relativePrefix != null && !file.isAbsolute())
@@ -856,13 +858,25 @@
// make sure it is canonical (no ../ and such)
file = file.getCanonicalFile();
- return file.toURL();
+ return file.toURI().toURL();
}
+ private static String decode(String filespec)
+ {
+ try
+ {
+ return URLDecoder.decode(filespec, "UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("Error decoding filespec: " + filespec, e);
+ }
+ }
+
private static URI makeURIFromFilespec(final String filespec, final String relativePrefix)
{
// make sure the file is absolute & canonical file url
- File file = new File(filespec);
+ File file = new File(decode(filespec));
// if we have a prefix and the file is not abs then prepend
if (relativePrefix != null && !file.isAbsolute())
More information about the jboss-svn-commits
mailing list