From: Jakub Narebski <jnareb@gmail.com>
To: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: filter escapes from longer commit titles that break firefox
Date: Sat, 25 Apr 2009 11:04:42 +0200 [thread overview]
Message-ID: <200904251104.45236.jnareb@gmail.com> (raw)
In-Reply-To: <200904250010.46299.jnareb@gmail.com>
On Sat, 25 April 2009, Jakub Narebski wrote:
> So it is not that simple...
That said, here is simple patch which should fix the bug you found.
It always creates sensible short and long values, contrary to your patch
(take a look at gitweb output after your patch, including tooltips on
mouseover).
But it is NOT TESTED if it works correctly, and if it covers all
occurrences. And it might be not necessary in all its complication:
we could simply replace control characters by '?' like in
chop_and_escape_str subroutine (which would also make gitweb more
consistent). It also lacks commit message.
Nevertheless it might be good bandaid for your problem:
-- >8 --
diff --git c/gitweb/gitweb.perl w/gitweb/gitweb.perl
index 3f99361..8575d5f 100755
--- c/gitweb/gitweb.perl
+++ w/gitweb/gitweb.perl
@@ -1035,6 +1035,24 @@ sub esc_url {
return $str;
}
+# quote and escape tag attribute values; autoEscape has to be turned off
+sub esc_attr {
+ my $str = shift;
+ return $str unless defined $str;
+
+ my %ent = ( # named HTML entities
+ '"' => '"',
+ '&' => '&',
+ '<' => '<',
+ '>' => '>',
+ );
+ $str = to_utf8($str);
+ $str =~ s|([\"&<>])|$ent{$1}|eg;
+ $str =~ s|([[:cntrl:]])|(($1 ne "\t") ? quot_upr($1) : $1)|eg;
+
+ return $str;
+}
+
# replace invalid utf8 character with SUBSTITUTION sequence
sub esc_html ($;%) {
my $str = shift;
@@ -1457,14 +1475,19 @@ sub format_subject_html {
my ($long, $short, $href, $extra) = @_;
$extra = '' unless defined($extra);
+ my $ret = '';
if (length($short) < length($long)) {
- return $cgi->a({-href => $href, -class => "list subject",
- -title => to_utf8($long)},
+ my $autoescape = $cgi->autoEscape(undef);
+ # or just replace s/([[:cntrl:]])/?/g in -title
+ $ret = $cgi->a({-href => $href, -class => "list subject",
+ -title => esc_attr($long)},
esc_html($short) . $extra);
+ $cgi->autoEscape($autoescape); # restore original value
} else {
- return $cgi->a({-href => $href, -class => "list subject"},
+ $ret = $cgi->a({-href => $href, -class => "list subject"},
esc_html($long) . $extra);
}
+ return $ret;
}
# format git diff header line, i.e. "diff --(git|combined|cc) ..."
prev parent reply other threads:[~2009-04-25 9:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 16:24 [PATCH] gitweb: filter escapes from longer commit titles that break firefox Paul Gortmaker
2009-04-20 9:32 ` Jakub Narebski
2009-04-20 13:29 ` Paul Gortmaker
2009-04-24 17:53 ` Jakub Narebski
2009-04-24 19:48 ` Paul Gortmaker
2009-04-24 22:10 ` Jakub Narebski
2009-04-25 9:04 ` Jakub Narebski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200904251104.45236.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).