--- /usr/lib/cgi-bin/cvsweb.orig	2005-07-27 20:07:49.000000000 +0200
+++ /usr/lib/cgi-bin/cvsweb	2005-07-27 20:37:49.000000000 +0200
@@ -299,10 +299,10 @@
 $where         =  $pathinfo;
 $doCheckout    =  $where =~ s|^/$CheckoutMagic/|/|o;
 $where         =~ s|^/||;
-$scriptname    =~ s|^/*|/|;
+$scriptname    =~ s|^/+|/|;
 
 # Let's workaround thttpd's stupidity..
-if ($scriptname =~ m|/$|) {
+if ($ENV{'SERVER_SOFTWARE'} =~ m|thttpd| && $scriptname =~ m|/$|) {
   $pathinfo .= '/';
   my $re = quotemeta $pathinfo;
   $scriptname =~ s/$re$//;
@@ -312,7 +312,7 @@
 # $where      : the path in the CVS repository (without leading /, or only /)
 # $scriptwhere: the URI escaped $scriptname + '/' + $where
 $scriptname   = uri_escape_path($scriptname);
-$scriptwhere  = join('/', $scriptname, uri_escape_path($where));
+$scriptwhere  = join('/', $scriptname, uri_escape_path($where)) if ($where);
 $where        = '/' if ($where eq '');
 
 # In text-based browsers, it's very annoying to have two links per file;
@@ -379,6 +379,7 @@
 
 my %query = ();
 if (defined($ENV{QUERY_STRING})) {
+  $ENV{QUERY_STRING} = uri_unescape($ENV{QUERY_STRING});
   for my $p (split(/[;&]+/, $ENV{QUERY_STRING})) {
     next unless $p;
     $p =~ y/+/ /;
