]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: esc_html (short) error message in die_error
authorJakub Narebski <redacted>
Sun, 7 Feb 2010 20:51:18 +0000 (21:51 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 384a68ebe1ac784b7bb276982b53258b74cb85dc39c4af72bddaded7ad2f739d..6804ead67be28162b41b5d8226f5cede6938e83ebbe02afdd777419118488b80 100755 (executable)
@@ -3376,7 +3376,7 @@ sub git_footer_html {
              "</html>";
 }
 
-# die_error(<http_status_code>, <error_message>)
+# die_error(<http_status_code>, <error_message>[, <detailed_html_description>])
 # Example: die_error(404, 'Hash not found')
 # By convention, use the following status codes (as defined in RFC 2616):
 # 400: Invalid or missing CGI parameters, or
@@ -3391,7 +3391,7 @@ sub git_footer_html {
 #      or down for maintenance).  Generally, this is a temporary state.
 sub die_error {
        my $status = shift || 500;
-       my $error = shift || "Internal server error";
+       my $error = esc_html(shift || "Internal Server Error");
        my $extra = shift;
 
        my %http_responses = (
This page took 0.322568 seconds and 4 git commands to generate.