Remove whitespace from client and version.

Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
Thomas Hochstein 2025-05-31 00:48:23 +02:00
parent ed3fb3cda0
commit 0102b72971
2 changed files with 5 additions and 2 deletions

View file

@ -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;
}

View file

@ -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.