From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Petr Baudis <pasky@suse.cz>
Subject: [PATCH 4/5] gitweb: Add git_url subroutine, and use it to quote full URLs
Date: Tue, 26 Sep 2006 01:58:41 +0200 [thread overview]
Message-ID: <200609260158.42247.jnareb@gmail.com> (raw)
In-Reply-To: <200609260153.08503.jnareb@gmail.com>
Add git_url subroutine, which does what git_param did before commit
a2f3db2f5de2a3667b0e038aa65e3e097e642e7d, and is used to quote full
URLs, currently only $home_link.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
It will also be used in patch inspired by
"[RFC][PATCH] gitweb: Make the Git logo link target to point to the homepage"
Message-ID: <7virjes7dq.fsf@assigned-by-dhcp.cox.net>
http://permalink.gmane.org/gmane.comp.version-control.git/27619
gitweb/gitweb.perl | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7fce9a6..b51e061 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -446,6 +446,15 @@ sub esc_param {
return $str;
}
+# quote unsafe chars in whole URL, so some charactrs cannot be quoted
+sub esc_url {
+ my $str = shift;
+ $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg;
+ $str =~ s/\+/%2B/g;
+ $str =~ s/ /\+/g;
+ return $str;
+}
+
# replace invalid utf8 character with SUBSTITUTION sequence
sub esc_html {
my $str = shift;
@@ -1362,7 +1371,7 @@ EOF
"<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
"<img src=\"$logo\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
"</a>\n";
- print $cgi->a({-href => esc_param($home_link)}, $home_link_str) . " / ";
+ print $cgi->a({-href => esc_url($home_link)}, $home_link_str) . " / ";
if (defined $project) {
print $cgi->a({-href => href(action=>"summary")}, esc_html($project));
if (defined $action) {
--
1.4.2.1
next prev parent reply other threads:[~2006-09-26 0:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-25 23:53 [PATCH 0/5] gitweb: A few code cleanup patches Jakub Narebski
2006-09-25 23:54 ` [PATCH 1/5] gitweb: Strip trailing slashes from $path in git_get_hash_by_path Jakub Narebski
2006-09-25 23:56 ` [PATCH 2/5] gitweb: Use "return" instead of "return undef" for some subs Jakub Narebski
2006-09-25 23:57 ` [PATCH 3/5] gitweb: Split validate_input into validate_pathname and validate_refname Jakub Narebski
2006-09-26 4:11 ` Junio C Hamano
2006-09-26 7:55 ` Jakub Narebski
2006-09-25 23:58 ` Jakub Narebski [this message]
2006-09-25 23:59 ` [PATCH 5/5] gitweb: Quote filename in HTTP Content-Disposition: header Jakub Narebski
2006-09-26 4:11 ` Junio C Hamano
2006-09-26 7:51 ` 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=200609260158.42247.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/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).