From 8b33e596c470e9216bd4c7e61bf2bfc889ea6673 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 20 Aug 2013 11:05:28 +0200 Subject: [PATCH 1/2] header.pl: Create new escape function that uses HTML::Entities. This partly replaces cleanhtml(), which is kept for backwards-compatibility and for a special case. --- config/cfgroot/header.pl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index a7f209d9c..9129c682c 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -12,6 +12,7 @@ package Header; use CGI(); +use HTML::Entities(); use Socket; use Time::Local; @@ -305,16 +306,16 @@ sub IpInSubnet return (($ip >= $start) && ($ip <= $end)); } -sub cleanhtml -{ +sub escape($) { + my $s = shift; + return HTML::Entities::encode_entities($s); +} + +sub cleanhtml { my $outstring =$_[0]; $outstring =~ tr/,/ / if not defined $_[1] or $_[1] ne 'y'; - $outstring =~ s/&/&/g; - $outstring =~ s/\'/'/g; - $outstring =~ s/\"/"/g; #" This is just a workaround for the syntax highlighter - $outstring =~ s//>/g; - return $outstring; + + return escape($outstring); } sub connectionstatus From 5ba9e6606e0a9666fb2bf83c68f1979f9dd2fbb2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 20 Aug 2013 11:06:36 +0200 Subject: [PATCH 2/2] proxylog.dat: Escape usernames. Bug #10406. --- html/cgi-bin/logs.cgi/proxylog.dat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/cgi-bin/logs.cgi/proxylog.dat b/html/cgi-bin/logs.cgi/proxylog.dat index e529be061..da86f8917 100644 --- a/html/cgi-bin/logs.cgi/proxylog.dat +++ b/html/cgi-bin/logs.cgi/proxylog.dat @@ -90,7 +90,7 @@ if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) $cgiparams{'MONTH'} = $temp[1]; $cgiparams{'DAY'} = $temp[2]; $cgiparams{'SOURCE_IP'} = $temp[3]; - $cgiparams{'USERNAME'} = $temp[4]; + $cgiparams{'USERNAME'} = &Header::escape($temp[4]); } if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || @@ -383,6 +383,7 @@ print <$so\n"; } print <