[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wget
Subject:    Re: HREF="//domain.com"
From:       Ian Abbott <abbotti () mev ! co ! uk>
Date:       2002-04-29 18:00:45
[Download RAW message or body]

On Mon, 29 Apr 2002 12:03:23 -0500 (CDT), you wrote:

>While using wget with www.slashdot.org, the site makes use of HREF's in 
>the following manner '<A HREF="//slashdot.org/image.gif">'.  It appears 
>that when wget is following the link, it is then looking for 
>"http://www.slashdot.org//slashdot.org/image.gif" which is incorrect.

That's fixed in CVS, so you can either build and install the version
in CVS or wait for the next official release.  Or just apply this
patch to Wget 1.8.1:

Index: src/url.c
===================================================================
RCS file: /pack/anoncvs/wget/src/url.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- src/url.c	2001/12/14 15:45:59	1.67
+++ src/url.c	2002/01/14 01:56:40	1.68
@@ -1575,6 +1575,37 @@
 	  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. */
+
+	  /* uri_merge("foo", "//new/bar")            -> "//new/bar"      */
+	  /* uri_merge("//old/foo", "//new/bar")      -> "//new/bar"      */
+	  /* uri_merge("http://old/foo", "//new/bar") -> "http://new/bar" */
+
+	  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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic