> -----Original Message----- > From: Junio C Hamano [mailto:junkio@xxxxxxx] > Sent: Friday, March 02, 2007 6:18 PM > To: Li Yang-r58472 > Cc: Jakub Narebski; rea-git@xxxxxxxxxxx; Raimund Bauer; git@xxxxxxxxxxxxxxx > Subject: Re: gitweb not friendly to firefox? > > "Li Yang-r58472" <LeoLi@xxxxxxxxxxxxx> writes: > > > Hi Jakub, > > > > Problem sovled, using the following patch. I'm not an expert of perl, > > so I don't know if it is problem of the gitweb or problem with my perl > > environment. My environment is perl-5.8.0 and perl-CGI-2.81. > > > > Signed-off-by: Li Yang<leoli@xxxxxxxxxxxx> > > --- > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > > index 653ca3c..8c9a291 100755 > > --- a/gitweb/gitweb.perl > > +++ b/gitweb/gitweb.perl > > @@ -591,7 +591,7 @@ sub esc_html ($;%) { > > my %opts = @_; > > > > $str = to_utf8($str); > > - $str = escapeHTML($str); > > + $str = $cgi->escapeHTML($str); > > if ($opts{'-nbsp'}) { > > $str =~ s/ / /g; > > } > > > > This is puzzling.... > > (1) we have two call sites of escapeHTML(), but your patch > touches only one. > > (2) we do "use CGI qw(:standard :escapeHTML -nosticky);" > upfront, presumably after doing this when we say > escapeHTML() it means the same as CGI::escapeHTML(). > > (3) we do "$cgi = new CGI" upfront. > > So I am wondering how the patch can have any effect... > > I am not saying that I do not believe you when you say the patch > fixes the problem for you. I just do not understand why and I > hate not knowing why something works. Here is the phenomenon I observed. In CGI.pm, # Escape HTML -- used internally 'escapeHTML' => <<'END_OF_FUNC', sub escapeHTML { # hack to work around earlier hacks push @_,$_[0] if @_==1 && $_[0] eq 'CGI'; my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_); return undef unless defined($toencode); return $toencode if ref($self) && !$self->{'escape'}; $toencode =~ s{&}{&}gso; $toencode =~ s{<}{<}gso; $toencode =~ s{>}{>}gso; $toencode =~ s{"}{"}gso; my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' || uc $self->{'.charset'} eq 'WINDOWS-1252'; if ($latin) { # bug in some browsers $toencode =~ s{'}{'}gso; $toencode =~ s{\x8b}{‹}gso; $toencode =~ s{\x9b}{›}gso; if (defined $newlinestoo && $newlinestoo) { $toencode =~ s{\012}{ }gso; $toencode =~ s{\015}{ }gso; } } return $toencode; } END_OF_FUNC The escapeHTML() returns on " return $toencode if ref($self) && !$self->{'escape'};". So the $self->{'ecscape'} = 0. However, $cgi->{'escape'} = 1. So I know, the $self is not the $cgi in gitweb, but another CGI with 'escape' undefined. - Leo - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html