Bug 29250

Summary: PROPFIND response does not handle trailing "/" as it "SHOULD"
Product: Slide Reporter: Wolfgang Gerteis <wolfgang.gerteis>
Component: WebDAV ServerAssignee: Slide Developer List <slide-dev>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: ---   
Hardware: All   
OS: other   

Description Wolfgang Gerteis 2004-05-27 17:29:39 UTC
PROPFIND response does not handle trailing "/" as it "SHOULD" according to
RFC 2518:

There is a standing convention that when a collection is referred to by its 
name without a trailing slash, the trailing slash is automatically appended.  
Due to this, a resource may accept a URI without a trailing "/" to point to a 
collection. In this case it SHOULD return a content-location header in the 
response pointing to the URI ending with the "/". For example, if a client 
invokes a method on http://foo.bar/blah (no trailing slash), the resource 
http://foo.bar/blah/ (trailing slash) may respond as if the operation were 
invoked on it, and should return a content-location header with 
http://foo.bar/blah/ in it. In general clients SHOULD use the "/" form of 
collection names. 

HTTP/1.1 207 Multi-Status

Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Wed, 26 May 2004 17:58:52 GMT
Server: Apache-Coyote/1.1

<D:response xmlns:D="DAV:">
    <D:href>/slide/files/folder-1932954899/folderC</D:href>
    <D:propstat>
        <D:prop>
            <D:creationdate>2004-05-26T17:58:49Z</D:creationdate>
            <D:displayname>folderC</D:displayname>
            <D:source></D:source>
            <D:lockdiscovery></D:lockdiscovery>
            <D:supportedlock>
                <D:lockentry>
                    <D:lockscope>
                        <D:exclusive></D:exclusive>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
                <D:lockentry>
                    <D:lockscope>
                        <D:shared></D:shared>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
            </D:supportedlock>
            <D:getlastmodified>Wed, 26 May 2004 17:58:49 
GMT</D:getlastmodified>
            <D:getcontentlength>0</D:getcontentlength>
            <D:modificationdate>2004-05-26T17:58:51Z</D:modificationdate>
            <D:resourcetype>
                <D:collection></D:collection>
            </D:resourcetype>
        </D:prop>
        <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
</D:response>

<D:response xmlns:D="DAV:">
    <D:href>/slide/files/folder-1932954899/folderC/folderE</D:href>
    <D:propstat>
        <D:prop>
            <D:creationdate>2004-05-26T17:58:51Z</D:creationdate>
            <D:displayname>folderE</D:displayname>
            <D:source></D:source>
            <D:lockdiscovery></D:lockdiscovery>
            <D:supportedlock>
                <D:lockentry>
                    <D:lockscope>
                        <D:exclusive></D:exclusive>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
                <D:lockentry>
                    <D:lockscope>
                        <D:shared></D:shared>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
            </D:supportedlock>
            <D:getlastmodified>Wed, 26 May 2004 17:58:51 
GMT</D:getlastmodified>
            <D:getcontentlength>0</D:getcontentlength>
            <D:modificationdate>2004-05-26T17:58:51Z</D:modificationdate>
            <D:resourcetype>
                <D:collection></D:collection>
            </D:resourcetype>
        </D:prop>
        <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
</D:response>

<D:response xmlns:D="DAV:">
    <D:href>/slide/files/folder-1932954899/folderC/folderD</D:href>
    <D:propstat>
        <D:prop>
            <D:creationdate>2004-05-26T17:58:50Z</D:creationdate>
            <D:displayname>folderD</D:displayname>
            <D:source></D:source>
            <D:lockdiscovery></D:lockdiscovery>
            <D:supportedlock>
                <D:lockentry>
                    <D:lockscope>
                        <D:exclusive></D:exclusive>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
                <D:lockentry>
                    <D:lockscope>
                        <D:shared></D:shared>
                    </D:lockscope>
                    <D:locktype>
                        <D:write></D:write>
                    </D:locktype>
                </D:lockentry>
            </D:supportedlock>
            <D:getlastmodified>Wed, 26 May 2004 17:58:50 
GMT</D:getlastmodified>
            <D:getcontentlength>0</D:getcontentlength>
            <D:modificationdate>2004-05-26T17:58:50Z</D:modificationdate>
            <D:resourcetype>
                <D:collection></D:collection>
            </D:resourcetype>
        </D:prop>
        <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
</D:response>

The folder names of the <D:href> elements "SHOULD" therefore end with a 
trailing "/".
Comment 1 Will Scheidegger 2005-10-02 11:26:29 UTC
I've tripped over this one too, trying to get an ls from an apache mod_webdav enabled server. Here's a 
fix to this problem:

In WebdavResources.java in the setWebdavProperties(Enumeration responses) method after

String myURI = httpURL.getEscapedURI();

do the following:
// 1. get the current href into a variable you can mess around with:
String helperHref = href;
// 2. check if it ends with a trailing slash
if (helperHref.endsWith("/")) {
    helperHref = helperHref.substring(0, helperHref.length()-1);
}
// 3. use the "fixed" helperHref in the next step
char[] childURI = (myURI + (myURI.endsWith("/") ? "" : "/") + URIUtil.getName(helperHref)).toCharArray();

Now if one of the slied committers could verify this fix and (if considerd o.k.) check it in, then this bug 
could be closed.

Cheers,
Will