From: Jason Yundt Date: Tue, 08 Mar 2022 01:07:11 GMT Subject: [PATCH v2 2/2] gitweb: remove invalid http-equiv="content-type" Message-ID: <20220308010711.61817-3-jason@jasonyundt.email> In-Reply-To: <20220307033723.175553-1-jason@jasonyundt.email> Before this change, gitweb would generate pages which included: A meta element with http-equiv="content-type" 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: Gitweb always generates XML documents, so its use of http-equiv="content-type" was invalid. This change replaces that tag with which is equivalent [1] and allowed in XML documents [2]. [1]: [2]: Signed-off-by: Jason Yundt --- gitweb/gitweb.perl | 2 +- t/t9502-gitweb-standalone-parse-output.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index fbd1c20a23..59457c1004 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -4225,7 +4225,7 @@ sub git_header_html { - + $title diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh index e7363511dd..0b06e2d6b0 100755 --- a/t/t9502-gitweb-standalone-parse-output.sh +++ b/t/t9502-gitweb-standalone-parse-output.sh @@ -207,4 +207,20 @@ test_expect_success 'xss checks' ' xss "" "$TAG+" ' +check_encoding_meta_element() { + gitweb_run "$@" && + ! grep -E "http-equiv=['\"]?content-type" gitweb.body && + grep -F '' gitweb.body +} + +# One of those can be used in XHTML, the other one can't. See: +# +# +test_expect_success 'no http-equiv="content-type", yes charset="utf-8"' ' + check_encoding_meta_element && + check_encoding_meta_element "p=.git" && + check_encoding_meta_element "p=.git;a=log" && + check_encoding_meta_element "p=.git;a=tree" +' + test_done -- 2.35.1