If your dav client is windows explorer and you are listing a webdav folder with a file with an & in the name, the name will not be displayed correctly. mod_dav is generating correct XML encoding for the filename so if the file is named "a & b.txt" then it will generate "a%20&%20b.txt" but windows explorer does not recognize this. Instead it wants to get "a%20%26%20b.txt" for this filename. If the function dav_xml_escape_uri is changed as follows the correct filename will be encoded and the listing will work properly in windows explorer. static const char *dav_xml_escape_uri(apr_pool_t *p, const char *uri) { const char *e_uri = ap_escape_uri(p, uri); + const char *scan; + apr_size_t len = 0; + apr_size_t extra = 0; + char *qstr; + char *qscan; + char c; /* check the easy case... */ if (ap_strchr_c(e_uri, '&') == NULL) return e_uri; /* there was a '&', so more work is needed... sigh. */ + for (scan = e_uri; (c = *scan) != '\0'; ++scan, ++len) { + if (c == '&') + extra += 2; /* %26 */ + } - /* - * Note: this is a teeny bit of overkill since we know there are no - * '<' or '>' characters, but who cares. - */ - return ap_xml_quote_string(p, e_uri, 0); + /* nothing to do? */ + if (extra == 0) + return e_uri; + + qstr = apr_palloc(p, len + extra + 1); + for (scan = e_uri, qscan = qstr; (c = *scan) != '\0'; ++scan) { + if (c == '&') { + *qscan++ = '%'; + *qscan++ = '2'; + *qscan++ = '6'; + } + else { + *qscan++ = c; + } + } + + *qscan = '\0'; + return qstr; }
Bleh. I just posted about this to the dav-dev mailing list. See: http://mailman.lyra.org/pipermail/dav-dev/2003-June/004761.html I consider this a bug in the client, rather than mod_dav. While the suggested fix does provide a legal/valid result, I'd prefer to avoid changing it. We could just find clients that break on the %26 style of behavior. Since what mod_dav is doing is legal, and my preference is to avoid the change, I'm closing this as WONTFIX. Julian: I believe this may be a good item for your Web Folders compatibility page.