ASF Bugzilla – Attachment 2346 Details for
Bug 10629
include directive fails when referencing Parent Path within a WAR
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for WARDirContext.java to resolve relative path issues
WARDirContext.diff (text/plain), 1.46 KB, created by
Andrew Conrad
on 2002-07-13 21:29:18 UTC
(
hide
)
Description:
Patch for WARDirContext.java to resolve relative path issues
Filename:
MIME Type:
Creator:
Andrew Conrad
Created:
2002-07-13 21:29:18 UTC
Size:
1.46 KB
patch
obsolete
>--- 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.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 10629
:
2301
| 2346