X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/c65ee6f7429eff9a7f58aad7c0aec858ad473092..cdeb354c4dbb11b683f9f8c5db2861f3dc572c61:/bin/logwatch diff --git a/bin/logwatch b/bin/logwatch index d5d2195..fdc2f25 100755 --- a/bin/logwatch +++ b/bin/logwatch @@ -99,7 +99,7 @@ $ignore = join('|',qw( .*:\s*$ ); -$/ = "\n\n"; +$/ = "\n\n"; $| = 1; if (-t STDIN or $ENV{GATEWAY_INTERFACE}) { @@ -118,6 +118,7 @@ for (;;) { foreach $weed (@weed) { while (s/\n$weed.*\n/\n/i) {} } + $post = /\nPOST\s/; if (/^\n*(CONNECT|CONTINUE).*\s\[([\d_]+)\]/i) { $pid = $2 } if (/\n(POST|GET)\s+\/(\w+)/i) { $cgi = $2 } if (/Content-Length: (\d+)/i) { @@ -154,7 +155,7 @@ for (;;) { read_skey($1); print "\n"; } - if ($debug and $pid and $cgi) { + if ($debug and $pid and $post) { &read_debug_log; }; $pid = $cgi = ''; @@ -167,14 +168,16 @@ sub read_debug_log { my (@log,$log); local $/ = "\n"; local $_; - local $^W; + # https://rt.cpan.org/Public/Bug/Display.html?id=88592 + # local $^W; # no warnings "all"; + no warnings 'utf8'; for (1..2) { sleep 1; @log = `ls -rt $logdir[0]/.debug/*_${pid}.$cgi 2>/dev/null`; if ($log = $log[-1] and open $log,$log) { - binmode($log,":encoding(UTF-8)"); + binmode($log,":utf8"); while (<$log>) { s/\r//; if (/^Content-Disposition:.*name="FILE".*filename="(.+)"/i) { @@ -184,9 +187,14 @@ sub read_debug_log { $_ = <$log>; my $v = <$log>||''; $v =~ s/[\r\n]+//; - printf " %s=\"%s\"\n",$p,utf8decode($v)||$v if $v; - read_akey($v) if $p eq 'AKEY'; - read_skey($v) if $p eq 'SKEY'; + if ($v) { + my $vv = utf8decode($v)||$v; + $vv =~ s/[\x00-\x1F]/_/g; + $vv =~ s/[\x80-\x9F]/_/g; + printf " %s=\"%s\"\n",$p,$vv; + read_akey($v) if $p eq 'AKEY'; + read_skey($v) if $p eq 'SKEY'; + } } elsif (/^(Param|Exp): (\w+=".+")/) { print " $2\n"; }