You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2003/01/07 00:43:33 UTC

DO NOT REPLY [Bug 15825] New: - filenames with & in them do not appear in file listing under windows explorer

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15825>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15825

filenames with & in them do not appear in file listing under windows explorer

           Summary: filenames with & in them do not appear in file listing
                    under windows explorer
           Product: Apache httpd-2.0
           Version: 2.0.43
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: mod_dav
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: lneumann@webct.com


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&amp;%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;
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org