Glen Sanft <[EMAIL PROTECTED]> writes: > This is not a problem which has just arisen in the recentest > release, but "#" in a path/file name, when properly escaped in a > URI, becomes itself in the filesystem, thus breaking the subsequent > local fetch.
It sounds like Wget should encode "#" as "%23" when generating the link. Does this patch work for you? 2004-03-04 Hrvoje Niksic <[EMAIL PROTECTED]> * convert.c (local_quote_string): Also quote "#" as "%23". Index: src/convert.c =================================================================== RCS file: /pack/anoncvs/wget/src/convert.c,v retrieving revision 1.7 diff -u -r1.7 convert.c --- src/convert.c 2003/11/08 04:55:44 1.7 +++ src/convert.c 2004/03/04 00:24:28 @@ -576,49 +576,49 @@ "index.html%3Ffoo=bar" would break local browsing, as the latter isn't even recognized as an HTML file! However, converting "index.html?foo=bar.html" to "index.html%3Ffoo=bar.html" should be - safe for both local and HTTP-served browsing. */ + safe for both local and HTTP-served browsing. + We always quote "#" as "%23" because # in a URL is a fragment + delimiter. */ + static char * local_quote_string (const char *file) { - const char *file_sans_qmark; - int qm; + const char *from; + char *newname, *to; + int newlen; - if (!opt.html_extension) - return html_quote_string (file); + int qmark = count_char (file, '?'); + int pound = count_char (file, '#'); - qm = count_char (file, '?'); + if (pound == 0 && (qmark == 0 || !opt.html_extension)) + return html_quote_string (file); - if (qm) - { - const char *from = file; - char *to, *newname; - - /* qm * 2 because we replace each question mark with "%3F", - i.e. replace one char with three, hence two more. */ - int fsqlen = strlen (file) + qm * 2; - - to = newname = (char *)alloca (fsqlen + 1); - for (; *from; from++) - { - if (*from != '?') - *to++ = *from; - else - { - *to++ = '%'; - *to++ = '3'; - *to++ = 'F'; - } - } - assert (to - newname == fsqlen); - *to = '\0'; - - file_sans_qmark = newname; - } - else - file_sans_qmark = file; + /* Add (qmark + pound) * 2 because we replace each such character + with "%3F", i.e. replace one char with three, hence two more. */ + newlen = strlen (file) + (qmark + pound) * 2; + + to = newname = (char *)alloca (newlen + 1); + for (from = file; *from; from++) + switch (*from) + { + case '?': + *to++ = '%'; + *to++ = '3'; + *to++ = 'F'; + break; + case '#': + *to++ = '%'; + *to++ = '2'; + *to++ = '3'; + break; + default: + *to++ = *from; + } + assert (to - newname == newlen); + *to = '\0'; - return html_quote_string (file_sans_qmark); + return html_quote_string (newname); } /* Book-keeping code for dl_file_url_map, dl_url_file_map,