]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
For xml build history, we need to encode strings for pagerefs and errors_404 to remov...
authoreldy <>
Tue, 27 Apr 2004 00:48:32 +0000 (00:48 +0000)
committereldy <>
Tue, 27 Apr 2004 00:48:32 +0000 (00:48 +0000)
wwwroot/cgi-bin/awstats.model.conf
wwwroot/cgi-bin/awstats.pl

index da19100b924dafd3c5f2e3c1da87a9977d93ea06..3624a12b718f5745925d3b124ce7a89df5281ef5 100644 (file)
@@ -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
 #
index c7fa4e94aadfdb2cd6c292e3b3ad59d0e3fddec8..92392d41cab49adf104111a15832bc17b2516764 100644 (file)
@@ -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/&/&amp;/g;
        return $string;
 }
 
+#------------------------------------------------------------------------------
+# Function:            Transforms & into &amp; 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/&/&amp;/g;
+       $string =~ s/</&lt;/g;
+       $string =~ s/>/&gt;/g;
+       return $string;
+}
+
 #------------------------------------------------------------------------------
 # Function:     Encode a binary string into an ASCII string
 # Parameters:  stringtoencode