Skip to content

Commit a262585

Browse files
Jayman2000gitster
authored andcommitted
gitweb: remove invalid http-equiv="content-type"
Before this change, gitweb would generate pages which included: <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/> When a meta's http-equiv equals "content-type", the http-equiv is said to be in the "Encoding declaration state". According to the HTML Standard, The Encoding declaration state may be used in HTML documents, but elements with an http-equiv attribute in that state must not be used in XML documents. Source: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type> This change removes that meta element since gitweb always generates XML documents. Signed-off-by: Jason Yundt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 943fd02 commit a262585

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4213,8 +4213,7 @@ sub git_header_html {
42134213
my %opts = @_;
42144214

42154215
my $title = get_page_title();
4216-
my $content_type = get_content_type_html();
4217-
print $cgi->header(-type=>$content_type, -charset => 'utf-8',
4216+
print $cgi->header(-type=>get_content_type_html(), -charset => 'utf-8',
42184217
-status=> $status, -expires => $expires)
42194218
unless ($opts{'-no_http_header'});
42204219
my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
@@ -4225,7 +4224,6 @@ sub git_header_html {
42254224
<!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
42264225
<!-- git core binaries version $git_version -->
42274226
<head>
4228-
<meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
42294227
<meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
42304228
<meta name="robots" content="index, nofollow"/>
42314229
<title>$title</title>

t/t9502-gitweb-standalone-parse-output.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,17 @@ test_expect_success 'xss checks' '
207207
xss "" "$TAG+"
208208
'
209209

210+
no_http_equiv_content_type() {
211+
gitweb_run "$@" &&
212+
! grep -E "http-equiv=['\"]?content-type" gitweb.body
213+
}
214+
215+
# See: <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-http-equiv-content-type>
216+
test_expect_success 'no http-equiv="content-type" in XHTML' '
217+
no_http_equiv_content_type &&
218+
no_http_equiv_content_type "p=.git" &&
219+
no_http_equiv_content_type "p=.git;a=log" &&
220+
no_http_equiv_content_type "p=.git;a=tree"
221+
'
222+
210223
test_done

0 commit comments

Comments
 (0)