tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources FileResources.java
Date Tue, 01 Aug 2000 03:06:41 GMT
remm        00/07/31 20:06:41

  Modified:    proposals/catalina/src/share/org/apache/tomcat/resources
                        FileResources.java
  Log:
  - Normalizing before validating paths.
    Jasper is no longer broken :-)
  
  Revision  Changes    Path
  1.6       +47 -29    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java
  
  Index: FileResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FileResources.java	2000/08/01 02:41:22	1.5
  +++ FileResources.java	2000/08/01 03:06:41	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
1.5 2000/08/01 02:41:22 remm Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/08/01 02:41:22 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/FileResources.java,v
1.6 2000/08/01 03:06:41 remm Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/08/01 03:06:41 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * since they were cached.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/08/01 02:41:22 $
  + * @version $Revision: 1.6 $ $Date: 2000/08/01 03:06:41 $
    */
   
   public final class FileResources extends ResourcesBase {
  @@ -162,10 +162,13 @@
        */
       public String getRealPath(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (null);
  +	validate(normalized);
   
   	// Return a real path if such a file actually exists
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.getAbsolutePath());
   	else
  @@ -214,12 +217,12 @@
        */
       public InputStream getResourceAsStream(String path) {
   
  -	validate(path);
  -
  -	// Look up the cached resource entry (if it exists) for this path
   	String normalized = normalize(path);
   	if (normalized == null)
   	    return (null);
  +	validate(normalized);
  +
  +	// Look up the cached resource entry (if it exists) for this path
   	ResourceBean resource = null;
   	synchronized (resourcesCache) {
   	    resource = (ResourceBean) resourcesCache.get(normalized);
  @@ -302,10 +305,13 @@
        */
       public long getResourceModified(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (-1L);
  +	validate(normalized);
   
           String contextPath = ((Context) container).getPath();
  -	File file = file(normalize(path));
  +	File file = file(normalized);
           if (file != null)
   	    return (file.lastModified());
   	else
  @@ -333,9 +339,12 @@
        */
       public long getResourceCreated(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (-1L);
  +	validate(normalized);
   
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.lastModified());
   	else
  @@ -355,13 +364,13 @@
        * @param path The path to the desired resource
        */
       public long getResourceLength(String path) {
  -
  -	validate(path);
   
  -	// Look up the cached resource entry (if it exists) for this path
  -	String normalized = normalize(path);
  +        String normalized = normalize(path);
   	if (normalized == null)
   	    return (-1L);
  +	validate(normalized);
  +
  +	// Look up the cached resource entry (if it exists) for this path
   	ResourceBean resource = null;
   	synchronized (resourcesCache) {
   	    resource = (ResourceBean) resourcesCache.get(normalized);
  @@ -371,7 +380,7 @@
           }
           
           // No entry was found in the cache
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.length());
   	else
  @@ -389,9 +398,12 @@
        */
       public boolean isCollection(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (false);
  +	validate(normalized);
   
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.isDirectory());
   	else
  @@ -409,13 +421,13 @@
        */
       public String[] getCollectionMembers(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (null);
  +	validate(normalized);
   
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null) {
  -            String normalized = normalize(path);
  -            if (normalized == null)
  -                return (null);
   	    String[] dirList = file.list();
               for (int i=0; i<dirList.length; i++) {
                   dirList[i] = normalize(normalized + "/" + dirList[i]);
  @@ -456,9 +468,12 @@
        */
       public boolean createCollection(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (false);
  +	validate(normalized);
   
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.mkdir());
   	else
  @@ -477,9 +492,12 @@
        */
       public boolean deleteResource(String path) {
   
  -	validate(path);
  +        String normalized = normalize(path);
  +	if (normalized == null)
  +	    return (false);
  +	validate(normalized);
   
  -	File file = file(normalize(path));
  +	File file = file(normalized);
   	if (file != null)
   	    return (file.delete());
   	else
  
  
  

Mime
View raw message