link-checker commit: Bring back <base href> handling code.

changeset:   406:d345cd6f0b09
tag:         tip
user:        Ville Skyttä <ville.skytta@iki.fi>
date:        Mon May 23 22:49:41 2011 +0300
files:       bin/checklink
description:
Bring back <base href> handling code.

LWP fails to do it for us when there are Content-Encodings involved:
https://rt.cpan.org/Ticket/Display.html?id=54361


diff -r f3c48c82ec04 -r d345cd6f0b09 bin/checklink
--- a/bin/checklink	Mon May 23 22:28:15 2011 +0300
+++ b/bin/checklink	Mon May 23 22:49:41 2011 +0300
@@ -238,6 +238,7 @@
     a => ['href'],
 
     # base/@href intentionally not checked
+    # http://www.w3.org/mid/200802091439.27764.ville.skytta%40iki.fi
     area       => ['href'],
     audio      => ['src'],
     blockquote => ['cite'],
@@ -2033,8 +2034,19 @@
 
         my $tag_local_base = undef;
 
+        # Special case: base/@href
+        # @@@TODO: The reason for handling <base href> ourselves is that LWP's
+        # head parsing magic fails at least for responses that have
+        # Content-Encodings: https://rt.cpan.org/Ticket/Display.html?id=54361
+        if ($tag eq 'base') {
+
+            # Ignore <base> with missing/empty href.
+            $self->{base} = $attr->{href}
+                if (defined($attr->{href}) && length($attr->{href}));
+        }
+
         # Special case: meta[@http-equiv=Refresh]/@content
-        if ($tag eq 'meta') {
+        elsif ($tag eq 'meta') {
             if ($attr->{'http-equiv'} &&
                 lc($attr->{'http-equiv'}) eq 'refresh')
             {

Received on Monday, 23 May 2011 19:49:51 UTC