]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/check-www-inbox.perl
public-inbox 1.1.0-pre1
[public-inbox.git] / t / check-www-inbox.perl
index 7cfe19328b7266d93200c434cb410833e9c0c97d..08e62471fedbda310b953b980ad2fee1817588d1 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # Parallel WWW checker
 my $usage = "$0 [-j JOBS] [-s SLOW_THRESHOLD] URL_OF_INBOX\n";
@@ -13,6 +13,7 @@ use LWP::ConnCache;
 use POSIX qw(:sys_wait_h);
 use Time::HiRes qw(gettimeofday tv_interval);
 use WWW::Mechanize;
+use Data::Dumper;
 my $nproc = 4;
 my $slow = 0.5;
 my %opts = (
@@ -130,10 +131,6 @@ sub worker_loop {
                        warn "W: ".$r->code . " $u\n"
                }
 
-               # check bad links
-               my @at = grep(/@/, @links);
-               print "BAD: $u ", join("\n", @at), "\n" if @at;
-
                my $s;
                # blocking
                foreach my $l (@links, "DONE\t$u") {
@@ -145,5 +142,16 @@ sub worker_loop {
                        my $n = length($l);
                        die "$$ send truncated $s < $n\n" if $s != $n;
                }
+
+               # make sure the HTML source doesn't screw up terminals
+               # when people curl the source (not remotely an expert
+               # on languages or encodings, here).
+               next if $r->header('Content-Type') !~ m!\btext/html\b!;
+               my $dc = $r->decoded_content;
+               if ($dc =~ /([\x00-\x08\x0d-\x1f\x7f-\x{99999999}]+)/s) {
+                       my $o = $1;
+                       my $c = Dumper($o);
+                       warn "bad: $u $c\n";
+               }
        }
 }