You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/09/01 12:11:51 UTC
svn commit: r1806940 - in /tomcat/tc7.0.x/trunk:
java/org/apache/naming/resources/FileDirContext.java
java/org/apache/naming/resources/LocalStrings.properties
java/org/apache/naming/resources/VirtualDirContext.java
webapps/docs/changelog.xml
Author: markt
Date: Fri Sep 1 12:11:51 2017
New Revision: 1806940
URL: http://svn.apache.org/viewvc?rev=1806940&view=rev
Log:
Correct regression in 7.0.80 that broke the use of relative paths with the extraResourcePaths attribute of a VirtualDirContext.
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/LocalStrings.properties
tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/VirtualDirContext.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java?rev=1806940&r1=1806939&r2=1806940&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/FileDirContext.java Fri Sep 1 12:11:51 2017
@@ -137,7 +137,15 @@ public class FileDirContext extends Base
throw new IllegalArgumentException(sm.getString("fileResources.base", docBase));
}
- this.absoluteBase = base.getAbsolutePath();
+ // absoluteBase also needs to be normalized. Using the canonical path is
+ // the simplest way of doing this.
+ try {
+ this.absoluteBase = base.getCanonicalPath();
+ } catch (IOException e) {
+ log.warn(sm.getString("fileResources.canonical.fail", base.getPath()));
+ // Fall back to the absolute path
+ this.absoluteBase = base.getAbsolutePath();
+ }
super.setDocBase(docBase);
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/LocalStrings.properties?rev=1806940&r1=1806939&r2=1806940&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/LocalStrings.properties (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/LocalStrings.properties Fri Sep 1 12:11:51 2017
@@ -14,6 +14,7 @@
# limitations under the License.
fileResources.base=Document base {0} does not exist or is not a readable directory
+fileResources.canonical.fail=A canonical path could not be determined for [{0}]
fileResources.listingNull=Could not get dir listing for {0}
warResources.notWar=Doc base must point to a WAR file
warResources.invalidWar=Invalid or unreadable WAR file : {0}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/VirtualDirContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/VirtualDirContext.java?rev=1806940&r1=1806939&r2=1806940&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/VirtualDirContext.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/resources/VirtualDirContext.java Fri Sep 1 12:11:51 2017
@@ -17,6 +17,7 @@
package org.apache.naming.resources;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -58,6 +59,10 @@ import org.apache.naming.NamingEntry;
* @author Fabrizio Giustina
*/
public class VirtualDirContext extends FileDirContext {
+
+ private static final org.apache.juli.logging.Log log=
+ org.apache.juli.logging.LogFactory.getLog(VirtualDirContext.class);
+
private String extraResourcePaths = "";
private Map<String, List<String>> mappedResourcePaths;
@@ -113,7 +118,13 @@ public class VirtualDirContext extends F
resourcePaths = new ArrayList<String>();
mappedResourcePaths.put(path, resourcePaths);
}
- resourcePaths.add(dir.getAbsolutePath());
+ try {
+ resourcePaths.add(dir.getCanonicalPath());
+ } catch (IOException e) {
+ log.warn(sm.getString("fileResources.canonical.fail", dir.getPath()));
+ // Fall back to the absolute path
+ resourcePaths.add(dir.getAbsolutePath());
+ }
}
}
if (mappedResourcePaths.isEmpty()) {
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1806940&r1=1806939&r2=1806940&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Sep 1 12:11:51 2017
@@ -64,6 +64,11 @@
<bug>61452</bug>: Fix a copy paste error that caused an
<code>UnsupportedEncodingException</code> when using WebDAV. (markt)
</fix>
+ <fix>
+ Correct regression in 7.0.80 that broke the use of relative paths with
+ the <code>extraResourcePaths</code> attribute of a
+ <code>VirtualDirContext</code>. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org