From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>,
"Li Yang-r58472" <LeoLi@freescale.com>,
"Jeff King" <peff@peff.net>
Subject: [PATCH] gitweb: Don't escape attributes in CGI.pm HTML methods
Date: Wed, 7 Mar 2007 02:21:25 +0100 [thread overview]
Message-ID: <200703070221.25519.jnareb@gmail.com> (raw)
In-Reply-To: <7vvehdnaib.fsf@assigned-by-dhcp.cox.net>
There is no need to escape HTML tag's attributes in CGI.pm
HTML methods (like CGI::a()), because CGI.pm does attribute
escaping automatically.
Explanation:
$cgi->a({ ... -attribute => atribute_value }, tag_contents)
is translated to
<a ... attribute="attribute_value">tag_contents</a>
The rules for escaping attribute values (which are string contents) are
different. For example you have to take care about escaping embedded '"'
and "'" characters; CGI::a() does that for us automatically.
CGI::a() cannot HTML escape tag contents automatically; we might want to
write
<a href="URL">some <b>bold</b> text</a>
for example. So we have to esc_html (or esc_path) if needed.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> In short: escape tag contents if needed, do not escape attrbure values.
>
> I trust a patch from you will follow shortly?
Here it is. I hope I found everything.
Commit message is bit long, so you can cut it to first sentence only
(or even only to title/subject).
gitweb/gitweb.perl | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 653ca3c..ea58946 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1974,17 +1974,17 @@ sub git_print_page_path {
$fullname .= ($fullname ? '/' : '') . $dir;
print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
hash_base=>$hb),
- -title => esc_html($fullname)}, esc_path($dir));
+ -title => $fullname}, esc_path($dir));
print " / ";
}
if (defined $type && $type eq 'blob') {
print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name,
hash_base=>$hb),
- -title => esc_html($name)}, esc_path($basename));
+ -title => $name}, esc_path($basename));
} elsif (defined $type && $type eq 'tree') {
print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
hash_base=>$hb),
- -title => esc_html($name)}, esc_path($basename));
+ -title => $name}, esc_path($basename));
print " / ";
} else {
print esc_path($basename);
--
1.5.0.2
next prev parent reply other threads:[~2007-03-07 1:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 3:58 [PATCH] gitweb: Change to use explicitly function call cgi->escapHTML() Li Yang
2007-03-06 6:55 ` Junio C Hamano
2007-03-06 9:34 ` Jakub Narebski
2007-03-06 9:39 ` Jeff King
2007-03-06 9:46 ` Junio C Hamano
2007-03-06 10:31 ` Li Yang-r58472
2007-03-06 10:41 ` Jeff King
2007-03-06 10:53 ` Junio C Hamano
2007-03-06 10:56 ` Jeff King
2007-03-06 10:58 ` Junio C Hamano
2007-03-06 11:01 ` Jeff King
2007-03-06 11:05 ` Junio C Hamano
2007-03-06 11:07 ` Jeff King
2007-03-06 11:07 ` Li Yang-r58472
2007-03-06 10:45 ` Junio C Hamano
2007-03-06 13:23 ` Jakub Narebski
2007-03-06 23:17 ` Junio C Hamano
2007-03-07 0:37 ` Jakub Narebski
2007-03-07 0:49 ` Junio C Hamano
2007-03-07 1:21 ` Jakub Narebski [this message]
2007-03-07 1:40 ` [PATCH] gitweb: Don't escape attributes in CGI.pm HTML methods Junio C Hamano
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=200703070221.25519.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=LeoLi@freescale.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=peff@peff.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.