Hi Stefano, please create a JIRA issue and attach your patch there. I'm currently busy preparing the 1.0.1 release and this will have to wait until we have it out of the door.
regards, Karl > Hi All, > > I've found a odd behavior in the method Bundle.getResource(String), the > method is not able to resolve the resource if the reource path contains: > '.' or '..' directory. > > I have already patched the: > org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getResource(String) > in order to accept the '..' and '.' path (see attchment). > > Can I commit the patch? > > > Ciao, > Stefano "Kismet" Lenzi > > P.S.: As you can see from my patch I do not consider the case when the > URL is encoded. > > P.P.S.: Should I report a issue on JIRA? > > > > Index: > src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java > =================================================================== > --- > src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java > (revision 576472) > +++ > src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java > (working copy) > @@ -22,12 +22,18 @@ > import java.io.InputStream; > import java.net.URL; > import java.security.ProtectionDomain; > +import java.util.ArrayList; > import java.util.Enumeration; > +import java.util.Iterator; > +import java.util.StringTokenizer; > import java.util.Vector; > > import org.apache.felix.framework.Logger; > import org.apache.felix.framework.util.SecureAction; > -import org.apache.felix.moduleloader.*; > +import org.apache.felix.moduleloader.IContent; > +import org.apache.felix.moduleloader.IContentLoader; > +import org.apache.felix.moduleloader.ISearchPolicy; > +import org.apache.felix.moduleloader.IURLPolicy; > > public class ContentLoaderImpl implements IContentLoader > { > @@ -129,13 +135,49 @@ > public URL getResource(String name) > { > URL url = null; > - > + > + //TODO Handling encoded URL > + > // Remove leading slash, if present. > if (name.startsWith("/")) > { > name = name.substring(1); > - } > - > + } > + > + /* > + * NORMALIZING PATH: > + * 1 - Removing /./ path > + * 2 - Resolving /../ path > + */ > + StringTokenizer tokenizer = new StringTokenizer(name,"/"); > + ArrayList parts = new ArrayList(); > + while(tokenizer.hasMoreTokens()) > + { > + String namePart = tokenizer.nextToken(); > + if(namePart.equals(".")) > + { > + continue; > + } > + else if(namePart.equals("..") && parts.size()>=1) > + { > + //XXX Should we launch an exception if there > are too many parent directory?!?!? > + parts.remove(parts.size()-1); > + } > + else > + { > + parts.add(namePart); > + } > + } > + > + //Rebuilding the path from parts > + name = ""; > + for (Iterator i = parts.iterator(); i.hasNext();) > + { > + String p = (String) i.next(); > + name += "/" + p; > + } > + name = name.substring(1); > + > // Check the module class path. > for (int i = 0; > (url == null) && > > -- Karl Pauls [EMAIL PROTECTED]