=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 1.1.1.7 retrieving revision 3.35 diff -u -p -r1.1.1.7 -r3.35 --- cvsweb/cvsweb.cgi 2000/09/23 20:23:34 1.1.1.7 +++ cvsweb/cvsweb.cgi 2000/10/10 21:14:05 3.35 @@ -43,7 +43,7 @@ # SUCH DAMAGE. # # $zId: cvsweb.cgi,v 1.103 2000/09/20 17:02:29 jumager Exp $ -# $kId: cvsweb.cgi,v 1.26 2000/09/22 11:13:17 knu Exp $ +# $Id: cvsweb.cgi,v 3.35 2000/10/10 21:14:05 knu Exp $ # ### @@ -59,7 +59,7 @@ use vars qw ( $checkoutMagic $doCheckout $scriptname $scriptwhere $where $pathinfo $Browser $nofilelinks $maycompress @stickyvars %funcline_regexp $is_mod_perl - $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased + $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased %input $query $barequery $sortby $bydate $byrev $byauthor $bylog $byfile $hr_default $logsort $cvstree $cvsroot $mimetype $defaultTextPlain $defaultViewable $allow_compress @@ -74,11 +74,12 @@ use vars qw ( $difffontsize $inputTextSize $mime_types $allow_annotate $allow_markup $use_java_script $open_extern_window $extern_window_width $extern_window_height $edit_option_form - $checkout_magic $show_subdir_lastmod $show_log_in_markup $v + $show_subdir_lastmod $show_log_in_markup $v $navigationHeaderColor $tableBorderColor $markupLogColor $tabstop $state $annTable $sel $curbranch @HideModules $module $use_descriptions %descriptions @mytz $dwhere $moddate $use_moddate $has_zlib $gzip_open + $LOG_FILESEPARATOR $LOG_REVSEPARATOR ); sub printDiffSelect($); @@ -115,6 +116,7 @@ sub download_url($$;$); sub download_link($$$;$); sub toggleQuery($$); sub urlencode($); +sub htmlquote($); sub http_header(;$); sub html_header($); sub html_footer(); @@ -125,14 +127,13 @@ sub forbidden_module($); use Cwd; # == EDIT this == -# User configuration is stored in -$config = undef; - -for ($ENV{CVSWEB_CONFIG}, -# '/home/knu/etc/cvsweb.conf', +# Locations to search for user configuration, in order: +for ( + $ENV{CVSWEB_CONFIG}, '/usr/local/etc/cvsweb.conf', - getcwd . '/cvsweb.conf') { - $config = $_ if defined($_) && -r $_; + getcwd() . '/cvsweb.conf' + ) { + $config = $_ if defined($_) && -r $_; } # == Configuration defaults == @@ -146,7 +147,7 @@ $allow_version_select = 1; # These are defined to allow checking with perl -cw %CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS = %MTYPES = %tags = %alltags = @tabcolors = (); -$cvstreedefault = $body_tag = $body_tag_for_src = +$cvstreedefault = $body_tag = $body_tag_for_src = $logo = $defaulttitle = $address = $long_intro = $short_instruction = $shortLogLen = $show_author = $dirtable = $tablepadding = $columnHeaderColorDefault = @@ -156,10 +157,13 @@ $diffcolorChange = $diffcolorAdd = $diffcolorDarkChang $difffontsize = $inputTextSize = $mime_types = $allow_annotate = $allow_markup = $use_java_script = $open_extern_window = $extern_window_width = $extern_window_height = $edit_option_form = -$checkout_magic = $show_subdir_lastmod = $show_log_in_markup = $v = +$show_subdir_lastmod = $show_log_in_markup = $v = $navigationHeaderColor = $tableBorderColor = $markupLogColor = $tabstop = $use_moddate = $moddate = $gzip_open = undef; +$LOG_FILESEPARATOR = q/^={77}$/; +$LOG_REVSEPARATOR = q/^-{28}$/; + ##### End of configuration variables ##### use Time::Local; @@ -193,12 +197,13 @@ $is_mod_perl = defined($ENV{MOD_PERL}); # per file, so disable the link at the icon # in this case: $Browser = $ENV{HTTP_USER_AGENT}; +$is_links = ($Browser =~ m`^Links `); $is_lynx = ($Browser =~ m`^Lynx/`i); $is_w3m = ($Browser =~ m`^w3m/`i); $is_msie = ($Browser =~ m`MSIE`); $is_mozilla3 = ($Browser =~ m`^Mozilla/[3-9]`); -$is_textbased = ($is_lynx || $is_w3m); +$is_textbased = ($is_links || $is_lynx || $is_w3m); $nofilelinks = $is_textbased; @@ -224,9 +229,11 @@ $maycompress = (((defined($ENV{HTTP_ACCEPT_ENCODING}) @stickyvars = qw(cvsroot hideattic sortby logsort f only_with_tag); if (-f $config) { - do $config; -} -else { + do $config + || &fatal("500 Internal Error", + sprintf('Error in loading configuration file: %s

%s
', + $config, &htmlify($@))); +} else { &fatal("500 Internal Error", 'Configuration not found. Set the variable $config ' . 'in cvsweb.cgi, or the environment variable ' @@ -278,25 +285,24 @@ foreach (keys %DEFAULTVALUE) } $barequery = ""; +my @barequery; foreach (@stickyvars) { # construct a query string with the sticky non default parameters set if (defined($input{$_}) && $input{$_} ne '' && !(defined($DEFAULTVALUE{$_}) && $input{$_} eq $DEFAULTVALUE{$_})) { - if ($barequery) { - $barequery = $barequery . "&"; - } - my $thisval = urlencode($_) . "=" . urlencode($input{$_}); - $barequery .= $thisval; + push @barequery, join('=', urlencode($_), urlencode($input{$_})); } } # is there any query ? -if ($barequery) { +if (@barequery) { + $barequery = join('&', @barequery); $query = "?$barequery"; - $barequery = "&" . $barequery; + $barequery = "&$barequery"; } else { $query = ""; } +undef @barequery; # get actual parameters $sortby = $input{"sortby"}; @@ -344,19 +350,30 @@ if ($input{'cvsroot'} && $CVSROOT{$input{'cvsroot'}}) $cvsroot = $CVSROOT{$cvstree}; # create icons out of description -foreach my $k (keys %ICONS) { +my $k; +foreach $k (keys %ICONS) { no strict 'refs'; my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}}; if ($ipath) { - ${"${k}icon"} = "\"$itxt\""; + ${"${k}icon"} = sprintf('%s', + htmlquote($ipath), htmlquote($itxt), $iwidth, $iheight) } else { ${"${k}icon"} = $itxt; } } +undef $k; +my $config_cvstree = "$config-$cvstree"; + # Do some special configuration for cvstrees -do "$config-$cvstree" if (-f "$config-$cvstree"); +if (-f $config_cvstree) { + do $config_cvstree + || &fatal("500 Internal Error", + sprintf('Error in loading configuration file: %s

%s
', + $config_cvstree, &htmlify($@))); +} +undef $config_cvstree; $prcategories = '(?:' . join('|', @prcategories) . ')'; $prcgi .= '%s' if defined($prcgi) && $prcgi !~ /%s/; @@ -468,10 +485,12 @@ elsif (-d $fullname) { print ""; - print "" if (!$byfile); - print "File"; - print "" if (!$byfile); + if ($byfile) { + print 'File'; + } else { + print &link('File', sprintf('./%s#dirlist', + &toggleQuery("sortby", "file"))); + } print ""; # do not display the other column-headers, if we do not have any files # with revision information: @@ -480,38 +499,47 @@ elsif (-d $fullname) { print ""; - print "" if (!$byrev); - print "Rev."; - print "" if (!$byrev); + if ($byrev) { + print 'Rev.'; + } else { + print &link('Rev.', sprintf('./%s#dirlist', + &toggleQuery("sortby", "rev"))); + } print ""; $infocols++; print ""; - print "" if (!$bydate); - print "Age"; - print "" if (!$bydate); + if ($bydate) { + print 'Age'; + } else { + print &link('Age', sprintf('./%s#dirlist', + &toggleQuery("sortby", "date"))); + } print ""; if ($show_author) { $infocols++; print ""; - print "" if (!$byauthor); - print "Author"; - print "" if (!$byauthor); + if ($byauthor) { + print 'Author'; + } else { + print &link('Author', sprintf('./%s#dirlist', + &toggleQuery("sortby", "author"))); + } print ""; } $infocols++; print ""; - print "" if (!$bylog); - print "Last log entry"; - print "" if (!$bylog); + if ($bylog) { + print 'Last log entry'; + } else { + print &link('Last log entry', sprintf('./%s#dirlist', + &toggleQuery("sortby", "log"))); + } print ""; } elsif ($use_descriptions) { @@ -540,9 +568,9 @@ elsif (-d $fullname) { closedir($dh); } - my $hideAtticToggleLink = "[Hide]" if (!$input{'hideattic'}); + my $hideAtticToggleLink = $input{'hideattic'} ? '' : + &link('[Hide]', sprintf('./%s#dirlist', + &toggleQuery ("hideattic"))); # Sort without the Attic/ pathname. # place directories first @@ -587,9 +615,9 @@ elsif (-d $fullname) { print $backicon; } else { - print &link($backicon,$url); + print &link($backicon, $url); } - print " ", &link("Previous Directory",$url); + print " ", &link("Previous Directory", $url); } else { $url = urlencode($_) . '/' . $query; @@ -598,13 +626,13 @@ elsif (-d $fullname) { print $diricon; } else { - print &link($diricon,$url); + print &link($diricon, $url); } - print " ", &link($_ . "/", $url), $attic; + print " ", &link("$_/", $url), $attic; if ($_ eq "Attic") { - print "  [Don't hide]"; + print "  "; + print &link("[Don't hide]", sprintf('./%s#dirlist', + &toggleQuery ("hideattic"))); } } # Show last change in dir @@ -675,8 +703,8 @@ elsif (-d $fullname) { print " ", &link($_, $url), $attic; print " " if ($dirtable); download_link($fileurl, - $rev, $rev, - $defaultViewable ? "text/x-cvsweb-markup" : undef); + $rev, $rev, + $defaultViewable ? "text/x-cvsweb-markup" : undef); print " " if ($dirtable); if ($date) { print " " . readableTime(time() - $date,0) . ""; @@ -906,33 +934,29 @@ sub findLastModifiedSubdirs(@) { } sub htmlify($;$) { - my($string, $extra) = @_; + (local $_, my $extra) = @_; - # Special Characters; RFC 1866 - $string =~ s/&/&/g; - $string =~ s/\"/"/g; - $string =~ s//>/g; + $_ = htmlquote($_); - # get URL's as link .. - $string =~ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`$1$2$3`g; # ` + # get URL's as link + s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`&link("$1$2$3", "$1$2$3")`ge; # ` # get e-mails as link - $string =~ s`([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})`$1`g; # ` + s`[-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4}`&link($&, "mailto:$&")`ge; # ` if ($extra) { - # get PR #'s as link .. + # get PR #'s as link: "PR#nnnn" "PR: nnnn, ..." "PR nnnn, ..." "bin/nnnn" if (defined($prcgi)) { - 1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1 . &link($2, sprintf($prcgi, $2))`ie; # ` - $string =~ s`\b${prcategories}/(\d+)\b`&link($&, sprintf($prcgi, $1))`igeo; # ` + 1 while s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1 . &link($2, sprintf($prcgi, $2))`ie; # `; + s`\b${prcategories}/(\d+)\b`&link($&, sprintf($prcgi, $1))`igeo; # `; } - # get manpage specs as link .. + # get manpage specs as link: "foo.1" "foo(1)" if (defined($mancgi)) { - $string =~ s`\b([a-zA-Z]\w+)\(([0-9n])\)\B`&link($&, sprintf($mancgi, $2, $1))`ge; # ` + s`\b([a-zA-Z]\w+)(?:\(([0-9n])\)\B|\.([0-9n])\b)`&link($&, sprintf($mancgi, $2 ne '' ? $2 : $3, $1))`ge; # `x; } } - return $string; + $_; } sub spacedHtmlText($;$) { @@ -968,7 +992,7 @@ sub spacedHtmlText($;$) { sub link($$) { my($name, $where) = @_; - return "$name\n"; + sprintf '%s', htmlquote($where), $name; } sub revcmp($$) { @@ -1016,7 +1040,7 @@ sub redirect($) { print "Location: $url\r\n"; } html_header("Moved"); - print "This document is located here.\n"; + print "This document is located ", &link('here', $url), "\n"; print &html_footer; exit(1); } @@ -1133,11 +1157,6 @@ sub doAnnotate($$) { ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//; ($filename = $where) =~ s/^.*\///; - http_header(); - - navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate"); - print "

Annotation of $pathname$filename, Revision $rev

\n"; - # this seems to be necessary $| = 1; $| = 0; # Flush @@ -1147,7 +1166,7 @@ sub doAnnotate($$) { # the public domain. # we could abandon the use of rlog, rcsdiff and co using # the cvsserver in a similiar way one day (..after rewrite) - $pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal Error", + $pid = open2($reader, $writer, "cvs -Rl server") || fatal ("500 Internal Error", "Fatal Error - unable to open cvs for annotation"); # OK, first send the request to the server. A simplified example is: @@ -1199,6 +1218,11 @@ sub doAnnotate($$) { # were nicer about buffering, then we could just leave it open, I think. close ($writer) || die "cannot close: $!"; + http_header(); + + navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate"); + print "

Annotation of $pathname$filename, Revision $rev

\n"; + # Ready to get the responses from the server. # For example: # E Annotations for foo/xx @@ -1231,33 +1255,41 @@ sub doAnnotate($$) { } elsif ($words[0] eq "M") { $lineNr++; - my $lrev = substr ($_, 2, 13); - my $lusr = substr ($_, 16, 9); - my $line = substr ($_, 36); + (my $lrev = substr($_, 2, 13)) =~ y/ //d; + (my $lusr = substr($_, 16, 9)) =~ y/ //d; + my $line = substr($_, 36); + my $isCurrentRev = ($rev eq $lrev); # we should parse the date here .. if ($lrev eq $oldLrev) { - $revprint = " "; + $revprint = sprintf('%-8s', ''); } else { - $revprint = $lrev; $oldLusr = ""; - $revprint =~ s`^(\S+)`$1`; # ` + $revprint = sprintf('%-8s', $lrev); + $revprint =~ s`\S+`&link($&, "$scriptwhere$barequery#rev$&")`e; # ` + $oldLusr = ''; } if ($lusr eq $oldLusr) { - $usrprint = " "; + $usrprint = ''; } else { $usrprint = $lusr; } $oldLrev = $lrev; $oldLusr = $lusr; - # is there a less timeconsuming way to strip spaces ? - ($lrev = $lrev) =~ s/\s+//g; - my $isCurrentRev = ($rev eq $lrev); - print "" if ($isCurrentRev); - printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr); + # Set bold for text-based browsers only - graphical + # browsers show bold fonts a bit wider than regular fonts, + # so it looks irregular. + print "" if ($isCurrentRev && $is_textbased); + + printf "%s%s %-8s %4d:", + $revprint, + $isCurrentRev ? '!' : ' ', + $usrprint, + $lineNr; print spacedHtmlText($line, $d{'tabstop'}); - print "" if ($isCurrentRev); + + print "" if ($isCurrentRev && $is_textbased); } elsif ($words[0] eq "ok") { # We could complain about any text received after this, like the @@ -1381,12 +1413,14 @@ sub cvswebMarkup($$$) { print "
"; print "
"; print "File: ", &clickablePath($where, 1); - print " "; - &download_link(urlencode($fileurl), $revision, "(download)"); + print " ("; + &download_link($fileurl, $revision, "download"); + print ")"; if (!$defaultTextPlain) { - print " "; - &download_link(urlencode($fileurl), $revision, "(as text)", + print " ("; + &download_link($fileurl, $revision, "as text", "text/plain"); + print ")"; } print "
\n"; if ($show_log_in_markup) { @@ -1402,10 +1436,10 @@ sub cvswebMarkup($$$) { my $url = download_url($fileurl, $revision, $mimetype); print "
"; if ($mimetype =~ /^image/) { - print "
"; + printf '
', htmlquote("$url$barequery"); } elsif ($mimetype =~ m%^application/pdf%) { - print "
"; + printf '
', htmlquote("$url$barequery"); } else { print "
";
@@ -1676,7 +1710,7 @@ again:
 	    $state = "head";
 	    goto again;
 	}
-	if ($state eq "head" && /^----------------------------$/) {
+	if ($state eq "head" && /$LOG_REVSEPARATOR/o) {
 	    $state = "log";
 	    $rev = undef;
 	    $date = undef;
@@ -1686,8 +1720,7 @@ again:
 	    next;
 	}
 	if ($state eq "log") {
-	    if (/^----------------------------$/
-		|| /^=============================/) {
+	    if (/$LOG_REVSEPARATOR/o || /$LOG_FILESEPARATOR/o) {
 		# End of a log entry.
 		my $revbranch;
 		($revbranch = $rev) =~ s/\.\d+$//;
@@ -1734,7 +1767,7 @@ again:
 		$log = $log . $_;
 	    }
 	}
-	if (/^===============/) {
+	if (/$LOG_FILESEPARATOR/o) {
 	    $state = "start";
 	    next;
 	}
@@ -1808,7 +1841,7 @@ sub readLog($;$) {
 # log info
 # ----------------------------
 	logentry:
-	while (!/^=========/) {
+	while (!/$LOG_FILESEPARATOR/o) {
 	    $_ = <$fh>;
 	    last logentry if (!defined($_));	# EOF
 	    print "R:", $_ if ($verbose);
@@ -1816,7 +1849,7 @@ sub readLog($;$) {
 		$rev = $1;
 		unshift(@allrevisions,$rev);
 	    }
-	    elsif (/^========/ || /^----------------------------$/) {
+	    elsif (/$LOG_FILESEPARATOR/o || /$LOG_REVSEPARATOR/o) {
 		next logentry;
 	    }
 	    else {
@@ -1850,7 +1883,7 @@ sub readLog($;$) {
 	    while (<$fh>) {
 		print "L:", $_ if ($verbose);
 		next line if (/^branches:\s/);
-		last line if (/^----------------------------$/ || /^=========/);
+		last line if (/$LOG_FILESEPARATOR/o || /$LOG_REVSEPARATOR/o);
 		$log{$rev} .= $_;
 	    }
 	    print "E:", $_ if ($verbose);
@@ -2002,29 +2035,40 @@ sub printLog($;$) {
 	    }
 	    print "\n Revision ";
 	    &download_link($fileurl, $_, $_,
-		$defaultViewable ? "text/x-cvsweb-markup" : undef);
+			   $defaultViewable ? "text/x-cvsweb-markup" : undef);
 	    if ($defaultViewable) {
-		print " / ";
-		&download_link($fileurl, $_, "(download)", $mimetype);
+		print " / (";
+		&download_link($fileurl, $_, "download", $mimetype);
+		print ")";
 	    }
 	    if (not $defaultTextPlain) {
-		print " / ";
-		&download_link($fileurl, $_, "(as text)",
-			   "text/plain");
+		print " / (";
+		&download_link($fileurl, $_, "as text", "text/plain");
+		print ")";
 	    }
 	    if (!$defaultViewable) {
-		print " / ";
-		&download_link($fileurl, $_, "(view)", "text/x-cvsweb-markup");
+		print " / (";
+		&download_link($fileurl, $_, "view", "text/x-cvsweb-markup");
+		print ")";
 	    }
 	    if ($allow_annotate) {
-		print " - ";
-		print "annotate";
+		print " - ";
+		print &link('annotate',
+			    sprintf('%s/%s?annotate=%s%s',
+				    $scriptname,
+				    urlencode($where),
+				    $_,
+				    $barequery));
 	    }
 	    # Plus a select link if enabled, and this version isn't selected
 	    if ($allow_version_select) {
 		if ((!defined($input{"r1"}) || $input{"r1"} ne $_)) {
-		    print " - [select for diffs]\n";
+		    print " - ";
+		    print &link('[select for diffs]',
+				sprintf('%s?r1=%s%s',
+					$scriptwhere,
+					$_,
+					$barequery));
 		}
 		else {
 		    print " - [selected]";
@@ -2079,22 +2123,33 @@ sub printLog($;$) {
 	    # Offer diff to previous revision
 	    if ($prev) {
 		$diffrev{$prev} = 1;
-		print " to previous $prev\n";
+
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $prev,
+				  $_,
+				  $barequery);
+
+		print " to previous ";
+		print &link($prev, $url);
 		if (!$hr_default) { # offer a human readable version if not default
-		    print "(colored)\n";
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	    #
 	    # Plus, if it's on a branch, and it's not a vendor branch,
 	    # offer a diff with the branch point.
 	    if ($revsym{$brp} && !/^1\.1\.1\.\d+$/ && !defined($diffrev{$brp})) {
-		print " to branchpoint $brp\n";
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $brp,
+				  $_,
+				  $barequery);
+
+		print " to branchpoint ";
+		print &link($brp, $url);
 		if (!$hr_default) { # offer a human readable version if not default
-		print "(colored)\n";
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	    #
@@ -2120,13 +2175,17 @@ sub printLog($;$) {
 		}
 		if (!defined($diffrev{$nextmain})) {
 		    $diffrev{$nextmain} = 1;
-		    print " next main $nextmain\n";
+
+		    my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				      $scriptwhere,
+				      $nextmain,
+				      $_,
+				      $barequery);
+
+		    print " next main ";
+		    print &link($nextmain, $url);
 		    if (!$hr_default) { # offer a human readable version if not default
-			print "(colored)\n";
+			print &link('colored', "$url&f=h");
 		    }
 		}
 	    }
@@ -2134,14 +2193,17 @@ sub printLog($;$) {
 	    # to make a diff to that revision
 	    if (defined($input{"r1"}) && !defined($diffrev{$input{"r1"}})) {
 		$diffrev{$input{"r1"}} = 1;
-		print " to selected $input{'r1'}\n";
-		if (!$hr_default) { # offer a human readable version if not default
-		    print "(colored)\n";
 
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $input{'r1'},
+				  $_,
+				  $barequery);
+
+		print " to selected ";
+		print &link($input{'r1'}, $url);
+		if (!$hr_default) { # offer a human readable version if not default
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	}
@@ -2161,11 +2223,10 @@ sub doLog($) {
         ($filename = $where) =~ s|^.*/||;
         $backurl = $scriptname . "/" . urlencode($upwhere) . $query;
 	print &link($backicon, "$backurl#$filename"),
-              " Up to ", &clickablePath($upwhere, 1), "

\n"; - print <Request diff between arbitrary revisions -


-EOF + " Up to ", &clickablePath($upwhere, 1), "

\n"; + print &link('Request diff between arbitrary revisions', '#diff'); + print '


'; + if ($curbranch) { print "Default branch: ", ($revsym{$curbranch} || $curbranch); } @@ -2193,7 +2254,7 @@ EOF print "

\n"; print "

\n"; foreach (@stickyvars) { - print "\n" + printf('', $_, $input{$_}) if (defined($input{$_}) && ((!defined($DEFAULTVALUE{$_}) || $input{$_} ne $DEFAULTVALUE{$_}) @@ -2470,12 +2531,12 @@ sub navigateHeader($$$$$) { $swhere = urlencode($filename) if ($swhere eq ""); print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; print "\n\n"; - print ''; + print ''; print "\n$path$filename - $title - $rev\n"; print "$body_tag_for_src\n"; print ""; print ""; @@ -2557,7 +2618,9 @@ sub clickablePath($$) { $retval = "[$cvstree]"; } else { - $retval = $retval . " [$cvstree]"; + $retval .= ' ' . &link("[$cvstree]", sprintf('%s/%s#dirlist', + $scriptname, + $query)); my $wherepath = ''; my ($lastslash) = $pathname =~ m|/$|; foreach (split(/\//, $pathname)) { @@ -2566,15 +2629,15 @@ sub clickablePath($$) { my ($last) = "$wherepath/" eq "/$pathname" || $wherepath eq "/$pathname"; if ($clickLast || !$last) { - $retval = $retval . "$_"; + $retval .= &link($_, join('', + $scriptname, + urlencode($wherepath), + (!$last || $lastslash ? '/' : ''), + $query, + (!$last || $lastslash ? "#dirlist" : ""))); } else { # do not make a link to the current dir - $retval = $retval . $_; + $retval .= $_; } } } @@ -2631,7 +2694,7 @@ sub chooseMirror() { print "\nThis cvsweb is mirrored in:\n"; foreach $mirror (keys %MIRRORS) { print ", " if ($moremirrors); - print qq($mirror\n); + print &link(htmlquote($mirror),$MIRRORS{$mirror}); $moremirrors = 1; } print "

\n"; @@ -2674,32 +2737,28 @@ sub download_url($$;$) { $revision =~ s/\b0\.//; - if (defined($checkout_magic) + if (defined($checkoutMagic) && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) { - my ($path); - ($path = $where) =~ s|/[^/]*$|/|; + my $path = $where; + $path =~ s|/[^/]*$|/|; $url = "$scriptname/$checkoutMagic/${path}$url"; } $url .= "?rev=$revision"; - $url .= "&content-type=$mimetype" if (defined($mimetype)); + $url .= '&content-type=' . urlencode($mimetype) if (defined($mimetype)); - return $url; + $url; } # Presents a link to download the # selected revision sub download_link($$$;$) { - my ($url,$revision,$textlink,$mimetype) = @_; - my ($fullurl) = download_url($url,$revision,$mimetype); - my ($paren) = $textlink =~ /^\(/; - $textlink =~ s/^\(// if ($paren); - $textlink =~ s/\)$// if ($paren); - print "(" if ($paren); - print "$textlink"; - print ")" if ($paren); } # Returns a Query string with the @@ -2750,7 +2814,7 @@ sub toggleQuery($$) { my ($value) = defined($vars{$var}) ? $vars{$var} : ""; my ($default) = defined($DEFAULTVALUE{$var}) ? $DEFAULTVALUE{$var} : ""; if ($value ne $default) { - $newquery .= "&" if ($newquery ne ""); + $newquery .= "&" if ($newquery ne ""); $newquery .= urlencode($var) . "=" . urlencode($value); } } @@ -2761,12 +2825,26 @@ sub toggleQuery($$) { } sub urlencode($) { - my ($in) = @_; - my ($out); - ($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge; - return $out; + local($_) = @_; + + s/[\000-+{-\377]/sprintf("%%%02x", ord($&))/ge; + + + $_; } +sub htmlquote($) { + local($_) = @_; + + # Special Characters; RFC 1866 + s/&/&/g; + s/\"/"/g; + s//>/g; + + $_; +} + sub http_header(;$) { my $content_type = shift || "text/html"; if (defined($moddate)) { @@ -2825,7 +2903,7 @@ sub http_header(;$) { sub html_header($) { my ($title) = @_; - my $version = '$zRevision: 1.103 $ $kRevision: 1.26 $'; #' + my $version = '$zRevision: 1.103 $ $Revision: 3.35 $'; #' http_header(); print <$sym"; + $ret .= &link($sym, $fileurl . toggleQuery('only_with_tag',$sym)); } - return $ret."\n"; + return "$ret\n"; } #

"; - print "$backicon"; + print &link($backicon, "$swhere$query#rev$rev"); print " Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log"; print " $fileicon