diff --git a/bin/gatherstats.pl b/bin/gatherstats.pl index 9cb0a9b..55c2dad 100755 --- a/bin/gatherstats.pl +++ b/bin/gatherstats.pl @@ -497,6 +497,9 @@ sub ClientStats { foreach (@Clients) { # filter agents for User-Agent with multiple agents next if $#Clients && exists($DropAgent{lc($_->{'agent'})}); + # remove whitespace + $_->{'agent'} =~ s/^\s+|\s+$//g; + $_->{'version'} =~ s/^\s+|\s+$//g if $_->{'version'}; # encode to utf-8, if necessary $_->{'agent'} = encode('UTF-8', $_->{'agent'}) if $_->{'agent'} =~ /[\x80-\x{ffff}]/; $_->{'version'} = encode('UTF-8', $_->{'version'}) if $_->{'version'} and $_->{'version'} =~ /[\x80-\x{ffff}]/; @@ -664,8 +667,7 @@ sub RemoveComments { # remove superfluous whitespace in header # and whitespace around header $Header =~ s/\s+/ /g; - $Header =~ s/^\s+//; - $Header =~ s/\s+$//; + $Header =~ s/^\s+|\s+$//g; return $Header; } diff --git a/doc/ChangeLog b/doc/ChangeLog index aa498ca..6bf2a46 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -11,6 +11,7 @@ NewsStats 0.4.0 (unreleased) * gatherstats: Don't die on parsing errors. * DBClnts: set version length to to 50. * gatherstats: Truncate overlong clients or versions. + * gatherstats: Remove whitespace from client and version. NewsStats 0.3.0 (2025-05-18) * Extract GroupStats (in gatherstats) to subroutine.