Skip to content

Commit 453541f

Browse files
jnarebgitster
authored andcommitted
gitweb: esc_html (short) error message in die_error
The error message (second argument to die_error) is meant to be short, one-line text description of given error. A few callers call die_error with error message containing unescaped user supplied data ($hash, $file_name). Instead of forcing callers to escape data, simply call esc_html on the parameter. Note that optional third parameter, which contains detailed error description, is meant to be HTML formatted, and therefore should be not escaped. While at it update esc_html synopsis/usage, and bring default error description to read 'Internal Server Error' (titlecased). Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6d81630 commit 453541f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gitweb/gitweb.perl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ sub git_footer_html {
33723372
"</html>";
33733373
}
33743374

3375-
# die_error(<http_status_code>, <error_message>)
3375+
# die_error(<http_status_code>, <error_message>[, <detailed_html_description>])
33763376
# Example: die_error(404, 'Hash not found')
33773377
# By convention, use the following status codes (as defined in RFC 2616):
33783378
# 400: Invalid or missing CGI parameters, or
@@ -3387,7 +3387,7 @@ sub git_footer_html {
33873387
# or down for maintenance). Generally, this is a temporary state.
33883388
sub die_error {
33893389
my $status = shift || 500;
3390-
my $error = shift || "Internal server error";
3390+
my $error = esc_html(shift || "Internal Server Error");
33913391
my $extra = shift;
33923392

33933393
my %http_responses = (

0 commit comments

Comments
 (0)