You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ad...@apache.org on 2009/07/09 08:36:45 UTC
svn commit: r792415 -
/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java
Author: adelmelle
Date: Thu Jul 9 06:36:44 2009
New Revision: 792415
URL: http://svn.apache.org/viewvc?rev=792415&view=rev
Log:
Decode URL using java.net.URLDecoder
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java?rev=792415&r1=792414&r2=792415&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java Thu Jul 9 06:36:44 2009
@@ -241,26 +241,24 @@
if (url == null || !url.getProtocol().equals("file")) {
return null;
} else {
- String filename = "";
- if (url.getHost() != null) {
- filename += Character.toString(File.separatorChar)
- + Character.toString(File.separatorChar)
- + url.getHost();
- }
- filename += url.getFile().replace('/', File.separatorChar);
- int pos = 0;
- while ((pos = filename.indexOf('%', pos)) >= 0) {
- if (pos + 2 < filename.length()) {
- String hexStr = filename.substring(pos + 1, pos + 3);
- char ch = (char) Integer.parseInt(hexStr, 16);
- filename = filename.substring(0, pos) + ch + filename.substring(pos + 3);
+ try {
+ String filename = "";
+ if (url.getHost() != null) {
+ filename += Character.toString(File.separatorChar)
+ + Character.toString(File.separatorChar)
+ + url.getHost();
}
- }
- final File f = new File(filename);
- if (!f.isFile()) {
+ filename += url.getFile().replace('/', File.separatorChar);
+ filename = java.net.URLDecoder.decode(filename, "UTF-8");
+ final File f = new File(filename);
+ if (!f.isFile()) {
+ return null;
+ }
+ return f;
+ } catch (java.io.UnsupportedEncodingException uee) {
+ assert false;
return null;
}
- return f;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org