Author: markt
Date: Sun Jul 31 16:59:39 2011
New Revision: 1152593
URL: http://svn.apache.org/viewvc?rev=1152593&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51584
Ensure file paths are encoded/decoded when translated to/from URLs so special
characters don't cause issues.
Modified:
tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
tomcat/trunk/webapps/docs/changelog.xml
Modified:
tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java?rev=1152593&r1=1152592&r2=1152593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
(original)
+++ tomcat/trunk/java/org/apache/naming/resources/DirContextURLConnection.java
Sun Jul 31 16:59:39 2011
@@ -22,6 +22,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.security.Permission;
import java.util.ArrayList;
import java.util.Collections;
@@ -153,6 +155,7 @@ public class DirContextURLConnection
path = path.substring(contextPath.length());
}
}
+ path = URLDecoder.decode(path, "UTF-8");
object = context.lookup(path);
attributes = context.getAttributes(path);
if (object instanceof Resource)
@@ -385,7 +388,8 @@ public class DirContextURLConnection
// Reopen resource
try {
- resource = (Resource) context.lookup(getURL().getFile());
+ resource = (Resource) context.lookup(
+ URLDecoder.decode(getURL().getFile(), "UTF-8"));
} catch (NamingException e) {
// Ignore
}
@@ -445,7 +449,8 @@ public class DirContextURLConnection
context.list(file.substring(start));
while (enumeration.hasMoreElements()) {
NameClassPair ncp = enumeration.nextElement();
- result.addElement(ncp.getName());
+ result.addElement(
+ URLEncoder.encode(ncp.getName(), "UTF-8"));
}
} catch (NamingException e) {
// Unexpected exception
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1152593&r1=1152592&r2=1152593&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sun Jul 31 16:59:39 2011
@@ -95,6 +95,11 @@
the current request thread name. Based on a patch from Felix
Schumacher.
(timw)
</add>
+ <fix>
+ <bug>51584</bug>: Ensure file paths are encoded/decoded when translated
+ to/from URLs when working with resources from a Context so special
+ characters don't cause issues. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]