]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitweb: remove invalid http-equiv="content-type"
authorJason Yundt <jason@jasonyundt.email>
Tue, 8 Mar 2022 15:56:12 +0000 (10:56 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Mar 2022 18:10:16 +0000 (10:10 -0800)
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 <jason@jasonyundt.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl
t/t9502-gitweb-standalone-parse-output.sh

index fbd1c20a232bb098509e0e25981de5016dea555f..606b50104c6b9b3beda8a3029fcd30dd553508d9 100755 (executable)
@@ -4213,8 +4213,7 @@ sub git_header_html {
        my %opts = @_;
 
        my $title = get_page_title();
-       my $content_type = get_content_type_html();
-       print $cgi->header(-type=>$content_type, -charset => 'utf-8',
+       print $cgi->header(-type=>get_content_type_html(), -charset => 'utf-8',
                           -status=> $status, -expires => $expires)
                unless ($opts{'-no_http_header'});
        my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
@@ -4225,7 +4224,6 @@ sub git_header_html {
 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
 <!-- git core binaries version $git_version -->
 <head>
-<meta http-equiv="content-type" content="$content_type; charset=utf-8"/>
 <meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
 <meta name="robots" content="index, nofollow"/>
 <title>$title</title>
index e7363511dd5b212423165880b078b76f24ec697e..8cb582f0e610d407ec5ba560740606629e5bc9da 100755 (executable)
@@ -207,4 +207,17 @@ test_expect_success 'xss checks' '
        xss "" "$TAG+"
 '
 
+no_http_equiv_content_type() {
+       gitweb_run "$@" &&
+       ! grep -E "http-equiv=['\"]?content-type" gitweb.body
+}
+
+# See: <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-http-equiv-content-type>
+test_expect_success 'no http-equiv="content-type" in XHTML' '
+       no_http_equiv_content_type &&
+       no_http_equiv_content_type "p=.git" &&
+       no_http_equiv_content_type "p=.git;a=log" &&
+       no_http_equiv_content_type "p=.git;a=tree"
+'
+
 test_done