use lib "$RealBin/..";
use lib "$RealBin/../web";
-use Test::More tests => 27;
+use Test::More tests => 21;
+use CGI qw/:standard/;
use strict;
use util;
is(1, util::count_lines("bar"));
is(1, util::count_lines(""));
-is("&", util::cgi_escape("&"));
-is("1 && 2", util::cgi_escape("1 && 2"));
-is("<>", util::cgi_escape("<>"));
-is("&amp;", util::cgi_escape("&"));
-is(""", util::cgi_escape("\""));
-is("nothing", util::cgi_escape("nothing"));
-
is("foo.bar", util::ChangeExtension("foo.old", "bar"));
is("foo.png", util::ChangeExtension("foo.png", "png"));
is("foobar.png", util::ChangeExtension("foobar", "png"));
use util;
use POSIX;
use Data::Dumper;
-use CGI;
+use CGI qw/:standard/;
use File::stat;
my $req = new CGI;
###############################################
# work out a URL so I can refer to myself in links
-my $myself = $req->self_url;
-if ($myself =~ /(.*)[?].*/) {
- $myself = $1;
-}
-if ($myself =~ /http:\/\/.*\/(.*)/) {
- $myself = $1;
-}
-
-# for now, hard code the self url - need to sanitize self_url
-$myself = "http://build.samba.org/";
+my $myself = $req->url();
################################################
# print an error on fatal errors
# change the given source paths into links
sub web_paths($$)
{
- my $tree = shift;
- my $paths = shift;
+ my ($tree, $paths) = @_;
my $ret = "";
if (grep {/$tree/} keys %cvs_trees) {
$ret .= sprintf($cvs_trees{$tree}, $1, $1);
$paths = $2;
}
- }
- elsif (grep {/$tree/} keys %svn_trees) {
+ } elsif (grep {/$tree/} keys %svn_trees) {
while ($paths =~ /\s*([^\s]+)(.*)/) {
$ret .= sprintf($svn_trees{$tree}, $1, $1);
$paths = $2;
}
- }
- elsif (grep {/$tree/} keys %bzr_trees) {
+ } elsif (grep {/$tree/} keys %bzr_trees) {
while ($paths =~ /\s*([^\s]+)(.*)/) {
$ret .= sprintf($bzr_trees{$tree}, $1, $1);
$paths = $2;
# show one row of history table
sub history_row($$)
{
- my $entry = shift;
- my $tree = shift;
- my $msg = util::cgi_escape($entry->{MESSAGE});
+ my ($entry, $tree) = @_;
+ my $msg = escapeHTML($entry->{MESSAGE});
my $t = POSIX::asctime(POSIX::gmtime($entry->{DATE}));
my $age = util::dhm_time(time()-$entry->{DATE});
# show one row of history table
sub history_row_text($$)
{
- my $entry = shift;
- my $tree = shift;
- my $msg = util::cgi_escape($entry->{MESSAGE});
+ my ($entry, $tree) = @_;
+ my $msg = escapeHTML($entry->{MESSAGE});
my $t = POSIX::asctime(POSIX::gmtime($entry->{DATE}));
my $age = util::dhm_time(time()-$entry->{DATE});
chomp $current_revision;
$current_revision =~ s/.*?(\d+)$/$1/;
- fatal("unknown revision") if ($revision !~ /^\d+$/ or $revision < 0 or
+ fatal("unknown revision") if ($revision !~ /^\d+$/ or $revision < 0 or
$revision > $current_revision);
my $log = util::LoadStructure("$HISTORYDIR/history.$tree");
if ($text_html eq "html") {
print "<!-- $cmd --!>\n";
- $diff = util::cgi_escape($diff);
+ $diff = escapeHTML($diff);
$diff = diff_pretty($diff);
print "<pre>$diff</pre>\n";
}
# show recent cvs entries
sub cvs_diff($$$$)
{
- my $author = shift;
- my $date = shift;
- my $tree = shift;
- my $text_html = shift;
+ my ($author, $date, $tree, $text_html) = @_;
my $module;
my $log = util::LoadStructure("$HISTORYDIR/history.$tree");
if ($text_html eq "html") {
print "<!-- $cmd --!>\n";
- $diff = util::cgi_escape($diff);
+ $diff = escapeHTML($diff);
$diff = diff_pretty($diff);
print "<pre>$diff</pre>\n";
} else {
if ($text_html eq "html") {
print "<!-- $cmd --!>\n";
- $diff = util::cgi_escape($diff);
+ $diff = escapeHTML($diff);
$diff = diff_pretty($diff);
print "<pre>$diff</pre>\n";
}
if ($text_html eq "html") {
print "<!-- $cmd --!>\n";
- $diff = util::cgi_escape($diff);
+ $diff = escapeHTML($diff);
$diff = diff_pretty($diff);
print "<pre>$diff</pre>\n";
- }
- else {
+ } else {
print "$diff\n";
}
}
# get commit history for the given tree
sub history($)
{
-
my $tree = shift;
my (%authors) = ('ALL' => 1);
my $author;