Skip to content

Commit 346d5e1

Browse files
jnarebJunio C Hamano
authored andcommitted
gitweb: Don't escape attributes in CGI.pm HTML methods
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. $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() does not HTML escape tag_contents; we would need to write <a href="URL">some <b>bold</b> text</a> for example. So we use esc_html (or esc_path) to escape tag_contents as needed. Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 290b146 commit 346d5e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,17 +1974,17 @@ sub git_print_page_path {
19741974
$fullname .= ($fullname ? '/' : '') . $dir;
19751975
print $cgi->a({-href => href(action=>"tree", file_name=>$fullname,
19761976
hash_base=>$hb),
1977-
-title => esc_html($fullname)}, esc_path($dir));
1977+
-title => $fullname}, esc_path($dir));
19781978
print " / ";
19791979
}
19801980
if (defined $type && $type eq 'blob') {
19811981
print $cgi->a({-href => href(action=>"blob_plain", file_name=>$file_name,
19821982
hash_base=>$hb),
1983-
-title => esc_html($name)}, esc_path($basename));
1983+
-title => $name}, esc_path($basename));
19841984
} elsif (defined $type && $type eq 'tree') {
19851985
print $cgi->a({-href => href(action=>"tree", file_name=>$file_name,
19861986
hash_base=>$hb),
1987-
-title => esc_html($name)}, esc_path($basename));
1987+
-title => $name}, esc_path($basename));
19881988
print " / ";
19891989
} else {
19901990
print esc_path($basename);

0 commit comments

Comments
 (0)