Skip to content

Commit

Permalink
gitweb: Add git_url subroutine, and use it to quote full URLs
Browse files Browse the repository at this point in the history
Add git_url subroutine, which does what git_param did before commit
a2f3db2, and is used to quote full
URLs, currently only $home_link.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Sep 27, 2006
1 parent 24d0693 commit f93bff8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,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;
Expand Down Expand Up @@ -1359,7 +1368,7 @@ sub git_header_html {
"<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) {
Expand Down

0 comments on commit f93bff8

Please sign in to comment.