You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mark Thomas <ma...@virgin.net> on 2003/09/27 01:24:55 UTC
[PATCH] Bug 23267
The attached patches address a couple of issue highlighted by bug 23267
- zero length contexts caused a NPE on contextFile.getParentFile()
- another exception on contextPath.substring(1) for zero length contexts
I also removed the filename.equals("ROOT") test as I couldn't see anywhere in
the docs where this is specified as mandatory.
Patches for TC5 and TC4 both attached (untested on TC5)
Mark
Index: catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catali
na/core/StandardHostDeployer.java,v
retrieving revision 1.15
diff -u -r1.15 StandardHostDeployer.java
--- catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java 2 Sep
2003 21:22:04 -0000 1.15
+++ catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java 26
Sep 2003 23:13:58 -0000
@@ -661,6 +661,10 @@
appBase = new File(System.getProperty("catalina.base"),
host.getAppBase());
File contextFile = new File(context.getDocBase());
+ // If doc base is relative, it is relative to appBase
+ if (!contextFile.isAbsolute())
+ contextFile = new File(appBase,context.getDocBase());
+
File baseDir = contextFile.getParentFile();
if ((baseDir == null)
|| (appBase.getCanonicalPath().equals
@@ -679,8 +683,16 @@
if (isWAR) {
filename = filename.substring(0,filename.length()-4);
}
- if (contextPath.length() == 0 && filename.equals("ROOT")
||
- filename.equals(contextPath.substring(1))) {
+
+ boolean toDelete = false;
+ if (contextPath.length() == 0) {
+ toDelete = true;
+ } else {
+ if (filename.equals(contextPath.substring(1)))
+ toDelete = true;
+ }
+
+ if (toDelete) {
if (!isWAR) {
long contextLastModified =
contextFile.lastModified();
Index: catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/co
re/StandardHostDeployer.java,v
retrieving revision 1.13
diff -u -r1.13 StandardHostDeployer.java
--- catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java 13
Jan 2003 23:23:28 -0000 1.13
+++ catalina/src/share/org/apache/catalina/core/StandardHostDeployer.java 26
Sep 2003 22:55:12 -0000
@@ -65,13 +65,10 @@
package org.apache.catalina.core;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
-import java.util.Enumeration;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Deployer;
@@ -85,7 +82,6 @@
import org.apache.catalina.startup.NamingRuleSet;
import org.apache.catalina.util.StringManager;
import org.apache.commons.digester.Digester;
-import org.xml.sax.SAXParseException;
/**
@@ -530,6 +526,9 @@
appBase = new File(System.getProperty("catalina.base"),
host.getAppBase());
File contextFile = new File(context.getDocBase());
+ // If doc base is relative, it is relative to appBase
+ if (!contextFile.isAbsolute())
+ contextFile = new File(appBase,context.getDocBase());
File baseDir = contextFile.getParentFile();
if
(appBase.getCanonicalPath().equals(baseDir.getCanonicalPath())) {
isAppBase = true;
@@ -546,8 +545,16 @@
if (isWAR) {
filename = filename.substring(0,filename.length()-4);
}
- if (contextPath.length() == 0 && filename.equals("ROOT")
||
- filename.equals(contextPath.substring(1))) {
+
+ boolean toDelete = false;
+ if (contextPath.length() == 0) {
+ toDelete = true;
+ } else {
+ if (filename.equals(contextPath.substring(1)))
+ toDelete = true;
+ }
+
+ if (toDelete) {
if (!isWAR) {
if (contextFile.isDirectory()) {
deleteDir(contextFile);
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org