From: Robert Schiele <rschiele@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Martin Koegler <mkoegler@auto.tuwien.ac.at>
Subject: [PATCH] Don't open a XML tag while another one is already open
Date: Sat, 16 Feb 2008 20:16:28 +0100 [thread overview]
Message-ID: <20080216191628.GK30676@schiele.dyndns.org> (raw)
chop_and_escape_str calls esc_html within a XML tag. Since esc_html
itself does escape control characters with quot_cec it could potentially
open another tag which leads to incorrect XML.
This patch adds an option "intag" to esc_html and quot_cec to indicate
that we are currently within a tag and thus suppresses opening another
one. It also makes use of this option in chop_and_escape_str.
Signed-off-by: Robert Schiele <rschiele@gmail.com>
---
This patch should fix the bug Martin Koegler reported in his mail "Invalid
html output repo.or.cz (alt-git.git)".
gitweb/gitweb.perl | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5e88637..a010c7a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -732,7 +732,7 @@ sub esc_html ($;%) {
if ($opts{'-nbsp'}) {
$str =~ s/ / /g;
}
- $str =~ s|([[:cntrl:]])|(($1 ne "\t") ? quot_cec($1) : $1)|eg;
+ $str =~ s|([[:cntrl:]])|(($1 ne "\t") ? quot_cec($1, -intag=>$opts{'-intag'}) : $1)|eg;
return $str;
}
@@ -753,6 +753,7 @@ sub esc_path {
# Make control characters "printable", using character escape codes (CEC)
sub quot_cec {
my $cntrl = shift;
+ my %opts = @_;
my %es = ( # character escape codes, aka escape sequences
"\t" => '\t', # tab (HT)
"\n" => '\n', # line feed (LF)
@@ -767,7 +768,11 @@ sub quot_cec {
my $chr = ( (exists $es{$cntrl})
? $es{$cntrl}
: sprintf('\%03o', ord($cntrl)) );
- return "<span class=\"cntrl\">$chr</span>";
+ if ($opts{'-intag'}) {
+ return "$chr";
+ } else {
+ return "<span class=\"cntrl\">$chr</span>";
+ }
}
# Alternatively use unicode control pictures codepoints,
@@ -866,7 +871,7 @@ sub chop_and_escape_str {
if ($chopped eq $str) {
return esc_html($chopped);
} else {
- return qq{<span title="} . esc_html($str) . qq{">} .
+ return qq{<span title="} . esc_html($str, -intag=>1) . qq{">} .
esc_html($chopped) . qq{</span>};
}
}
--
1.5.2.4
next reply other threads:[~2008-02-16 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-16 19:16 Robert Schiele [this message]
2008-02-17 17:48 ` [PATCH] gitweb: Add new option -nohtml to quot_xxx subroutines Jakub Narebski
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=20080216191628.GK30676@schiele.dyndns.org \
--to=rschiele@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mkoegler@auto.tuwien.ac.at \
/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).