From: eldy <> Date: Tue, 27 Apr 2004 00:48:32 +0000 (+0000) Subject: For xml build history, we need to encode strings for pagerefs and errors_404 to remov... X-Git-Tag: AWSTATS_6_1_BETA~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e2eae7ee817c777f4225d7bb754f82c57660270;p=thirdparty%2FAWStats.git For xml build history, we need to encode strings for pagerefs and errors_404 to remove reserved xtml words inside strings --- diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index da19100b..3624a12b 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -351,6 +351,10 @@ CreateDirDataIfNotExists=0 # You can choose in which format the Awstats history database is saved. +# Note: xml database requires twice more disk space than text database. +# Note: xml database is a new feature (only two month world test) so use it +# with care. Prefer text database +# Change : Effective after next update # Possible values: text or xml # Default: text # @@ -360,6 +364,7 @@ BuildHistoryFormat=text # If you prefer having the report output pages be built as XML compliant pages # instead of simple HTML pages, you can set this to 'xhtml' (May not works # properly with old browsers). +# Change : Effective immediatly # Possible values: html or xhtml # Default: html # diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index c7fa4e94..92392d41 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -3753,15 +3753,13 @@ sub Save_History { $keysinkeylist{$_}=1; my $newkey=$_; $newkey =~ s/^http(s|):\/\/([^\/]+)\/$/http$1:\/\/$2/i; # Remove / at end of http://.../ but not at end of http://.../dir/ - $newkey =~ s/\s/%20/g; - print HISTORYTMP "${xmlrb}$newkey${xmlrs}".int($_pagesrefs_p{$_}||0)."${xmlrs}$_pagesrefs_h{$_}${xmlre}\n"; + print HISTORYTMP "${xmlrb}".XMLEncodeForH($newkey)."${xmlrs}".int($_pagesrefs_p{$_}||0)."${xmlrs}$_pagesrefs_h{$_}${xmlre}\n"; } foreach (keys %_pagesrefs_h) { if ($keysinkeylist{$_}) { next; } my $newkey=$_; $newkey =~ s/^http(s|):\/\/([^\/]+)\/$/http$1:\/\/$2/i; # Remove / at end of http://.../ but not at end of http://.../dir/ - $newkey =~ s/\s/%20/g; - print HISTORYTMP "${xmlrb}$newkey${xmlrs}".int($_pagesrefs_p{$_}||0)."${xmlrs}$_pagesrefs_h{$_}${xmlre}\n"; + print HISTORYTMP "${xmlrb}".XMLEncodeForH($newkey)."${xmlrs}".int($_pagesrefs_p{$_}||0)."${xmlrs}$_pagesrefs_h{$_}${xmlre}\n"; } print HISTORYTMP "${xmleb}END_PAGEREFS${xmlee}\n"; } @@ -3853,8 +3851,8 @@ sub Save_History { print HISTORYTMP "${xmlbb}BEGIN_SIDER_$code${xmlbs}".(scalar keys %_sider404_h)."${xmlbe}\n"; foreach (keys %_sider404_h) { my $newkey=$_; - my $newreferer=$_referer404_h{$_}||''; $newreferer =~ s/\s/%20/g; - print HISTORYTMP "${xmlrb}$newkey${xmlrs}$_sider404_h{$_}${xmlrs}$newreferer${xmlre}\n"; + my $newreferer=$_referer404_h{$_}||''; + print HISTORYTMP "${xmlrb}".XMLEncodeForH($newkey)."${xmlrs}$_sider404_h{$_}${xmlrs}".XMLEncodeForH($newreferer)."${xmlre}\n"; } print HISTORYTMP "${xmleb}END_SIDER_$code${xmlee}\n"; } @@ -4130,12 +4128,27 @@ sub ChangeWordSeparatorsIntoSpace { # Return: encodedstring #------------------------------------------------------------------------------ sub XMLEncode { + if ($BuildReportFormat ne 'xhtml' && $BuildReportFormat ne 'xml') { return shift; } my $string = shift; - if ($BuildReportFormat ne 'xhtml' && $BuildReportFormat ne 'xml') { return $string; } $string =~ s/&/&/g; return $string; } +#------------------------------------------------------------------------------ +# Function: Transforms & into & as needed in XML/XHTML +# Parameters: stringtoencode +# Return: encodedstring +#------------------------------------------------------------------------------ +sub XMLEncodeForH { + my $string = shift; + $string =~ s/\s/%20/g; + if ($BuildHistoryFormat ne 'xml') { return $string; } + $string =~ s/&/&/g; + $string =~ s//>/g; + return $string; +} + #------------------------------------------------------------------------------ # Function: Encode a binary string into an ASCII string # Parameters: stringtoencode