On 4 Jan 2002 at 12:22, Bastiaan Stougie wrote:
> wget -P $LOCALDIR -m -np -nH -p --cut-dirs=2
> http://host/dir1/dir2/
>
> This works fine, except that wget does not follow all the urls. It
> skips urls like:
>
> <A HREF="//host/dir1/dir2/file">text</A>
Here is a proposed patch to fix that.
src/ChangeLog entry:
2002-01-07 Ian Abbott <[EMAIL PROTECTED]>
* url.c (uri_merge_1): Deal with "net path" relative URL (one that
starts with "//").
And the actual patch:
Index: src/url.c
===================================================================
RCS file: /pack/anoncvs/wget/src/url.c,v
retrieving revision 1.67
diff -u -r1.67 url.c
--- src/url.c 2001/12/14 15:45:59 1.67
+++ src/url.c 2002/01/07 15:30:41
@@ -1575,6 +1575,35 @@
memcpy (constr + baselength, link, linklength);
constr[baselength + linklength] = '\0';
}
+ else if (linklength > 1 && *link == '/' && *(link + 1) == '/')
+ {
+ /* LINK begins with "//" and so is a net path: we need to
+ replace everything after (and including) the double slash
+ with LINK.
+
+ So, if BASE is "http://oldhost/whatever/foo/bar", and LINK
+ is "//newhost/qux/xyzzy", our result should be
+ "http://newhost/qux/xyzzy". */
+ int span;
+ const char *slash;
+ const char *start_insert;
+ /* Look for first slash. */
+ slash = memchr (base, '/', end - base);
+ /* If found slash and it is a double slash, then replace
+ from this point,
+ else default to replacing from the beginning. */
+ if (slash && *(slash + 1) == '/')
+ start_insert = slash;
+ else
+ start_insert = base;
+
+ span = start_insert - base;
+ constr = (char *)xmalloc (span + linklength + 1);
+ if (span)
+ memcpy (constr, base, span);
+ memcpy (constr + span, link, linklength);
+ constr[span + linklength] = '\0';
+ }
else if (*link == '/')
{
/* LINK is an absolute path: we need to replace everything