DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10629>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10629 include directive fails when referencing Parent Path within a WAR ------- Additional Comments From [EMAIL PROTECTED] 2002-07-13 21:27 ------- It seems that ZIP format accepts directory paths such as /dir/../testfile.htm as a valid entry and stores the file as so. Assumming that is a correct implementation, the parent directory and current directory notation should be dealt with Prior to requesting the file from the ZipFile. Since other DirContext's may handle relative paths, (FileDirContext does) I patched org.apache.naming.resources.WARDirContext.java, resolving the relative paths before retrieval. --- WARDirContext.old 2002-07-13 06:04:37.000000000 -0400 +++ WARDirContext.java 2002-07-13 06:30:59.000000000 -0400 @@ -246,6 +246,7 @@ throws NamingException { if (name.isEmpty()) return this; + name = handleRelativePaths(name); //removes Dot and DotDot notation Entry entry = treeLookup(name); if (entry == null) throw new NamingException @@ -772,6 +773,35 @@ } + /** + * Handle Relative file path markers such as .. and . + * Assumes that the name will begin "/" and will maintain this + */ + protected static Name handleRelativePaths(Name BaseName) + throws NamingException { + boolean hasChanged = true; + Name name = BaseName.getSuffix(0); //creating a new name, so as not to modify the old + while(hasChanged) { + hasChanged = false; + for(int i = 0; i < name.size(); i++) { + //remove any Dot Dot notation, if it's not the root + if( name.get(i).equals("..") && i > 1) { //will not handle the case "/.." . let current system handle situation + name.remove(i); + name.remove(i - 1); + hasChanged = true; + break; //start over + } + + //removes any Single Dot notation + if( name.get(i).equals(".") ) { + name.remove(i); + hasChanged = true; + break; //start over + } + } + } + return name; + } /** * Constructs a tree of the entries contained in a WAR file. --- file end ---- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>