juergen     01/02/20 01:24:02

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        WebdavMethod.java
               src/webdav/server/org/apache/slide/webdav WebdavServlet.java
  Log:
  if a store (at propFind) throws a NPE the response code is changed to 
InternalServerErrror and the server prints a stackTrace.
  
  Revision  Changes    Path
  1.12      +48 -46    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
  
  Index: WebdavMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WebdavMethod.java 2001/02/15 17:44:04     1.11
  +++ WebdavMethod.java 2001/02/20 09:24:01     1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
 1.11 2001/02/15 17:44:04 remm Exp $
  - * $Revision: 1.11 $
  - * $Date: 2001/02/15 17:44:04 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
 1.12 2001/02/20 09:24:01 juergen Exp $
  + * $Revision: 1.12 $
  + * $Date: 2001/02/20 09:24:01 $
    *
    * ====================================================================
    *
  @@ -329,6 +329,7 @@
           } catch (WebdavException ex) {
               throw ex;
           } catch (Exception ex) {
  +            resp.setStatus(WebdavStatus.SC_METHOD_FAILURE);
               throw new WebdavException(WebdavStatus.SC_METHOD_FAILURE);
           } finally {
               if (transactionIsStarted && methodNeedsTransactionSupport()) {
  @@ -568,10 +569,10 @@
           if (path == null)
               return null;
   
  -     // Resolve encoded characters in the normalized path,
  -     // which also handles encoded spaces so we can skip that later.
  -     // Placed at the beginning of the chain so that encoded 
  -     // bad stuff(tm) can be caught by the later checks
  +        // Resolve encoded characters in the normalized path,
  +        // which also handles encoded spaces so we can skip that later.
  +        // Placed at the beginning of the chain so that encoded
  +        // bad stuff(tm) can be caught by the later checks
           String normalized = path;
           if (normalized.indexOf('%') >= 0)
               // FIXME: Use configurable encoding here.
  @@ -579,51 +580,51 @@
           if (normalized == null)
               return (null);
           
  -     // Normalize the slashes and add leading slash if necessary
  -     if (normalized.indexOf('\\') >= 0)
  -         normalized = normalized.replace('\\', '/');
  -     if (!normalized.startsWith("/"))
  -         normalized = "/" + normalized;
  -
  -     // Resolve occurrences of "//" in the normalized path
  -     while (true) {
  -         int index = normalized.indexOf("//");
  -         if (index < 0)
  -             break;
  -         normalized = normalized.substring(0, index) +
  -             normalized.substring(index + 1);
  -     }
  -
  -     // Resolve occurrences of "/./" in the normalized path
  -     while (true) {
  -         int index = normalized.indexOf("/./");
  -         if (index < 0)
  -             break;
  -         normalized = normalized.substring(0, index) +
  -             normalized.substring(index + 2);
  -     }
  -
  -     // Resolve occurrences of "/../" in the normalized path
  -     while (true) {
  -         int index = normalized.indexOf("/../");
  -         if (index < 0)
  -             break;
  -         if (index == 0)
  -             return (null);  // Trying to go outside our context
  -         int index2 = normalized.lastIndexOf('/', index - 1);
  -         normalized = normalized.substring(0, index2) +
  -             normalized.substring(index + 3);
  -     }
  -
  -     // Return the normalized path that we have completed
  -     return (normalized);
  +        // Normalize the slashes and add leading slash if necessary
  +        if (normalized.indexOf('\\') >= 0)
  +            normalized = normalized.replace('\\', '/');
  +        if (!normalized.startsWith("/"))
  +            normalized = "/" + normalized;
  +    
  +        // Resolve occurrences of "//" in the normalized path
  +        while (true) {
  +            int index = normalized.indexOf("//");
  +            if (index < 0)
  +            break;
  +            normalized = normalized.substring(0, index) +
  +            normalized.substring(index + 1);
  +        }
  +    
  +        // Resolve occurrences of "/./" in the normalized path
  +        while (true) {
  +            int index = normalized.indexOf("/./");
  +            if (index < 0)
  +            break;
  +            normalized = normalized.substring(0, index) +
  +            normalized.substring(index + 2);
  +        }
  +    
  +        // Resolve occurrences of "/../" in the normalized path
  +        while (true) {
  +            int index = normalized.indexOf("/../");
  +            if (index < 0)
  +            break;
  +            if (index == 0)
  +            return (null);  // Trying to go outside our context
  +            int index2 = normalized.lastIndexOf('/', index - 1);
  +            normalized = normalized.substring(0, index2) +
  +            normalized.substring(index + 3);
  +        }
  +    
  +        // Return the normalized path that we have completed
  +        return (normalized);
   
       }
   
   
       /**
        * URL rewriter.
  -     * 
  +     *
        * @param path Path which has to be rewiten
        */
       protected static String URLEncode(String path) {
  @@ -634,3 +635,4 @@
       
       
   }
  +
  
  
  
  1.6       +5 -3      
jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WebdavServlet.java        2001/02/20 09:16:57     1.5
  +++ WebdavServlet.java        2001/02/20 09:24:02     1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 
1.5 2001/02/20 09:16:57 juergen Exp $
  - * $Revision: 1.5 $
  - * $Date: 2001/02/20 09:16:57 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v 
1.6 2001/02/20 09:24:02 juergen Exp $
  + * $Revision: 1.6 $
  + * $Date: 2001/02/20 09:24:02 $
    *
    * ====================================================================
    *
  @@ -308,6 +308,7 @@
               // There has been an error somewhere ...
               // TODO : Show error page.
               System.out.println(e.getMessage());
  +            e.printStackTrace();
           } catch (Throwable e) {
               // If something goes really wrong ...
               e.printStackTrace();
  @@ -400,4 +401,5 @@
       }
       
   }
  +
   
  
  
  

Reply via email to