{"thread":{"id":"57513","subject":"[PATCH 1/2] comment: fix typo","startedAt":"2022-03-07T03:45:34Z","lastAt":"2022-03-08T15:59:02Z","messageCount":17,"participants":["Jason Yundt","Ævar Arnfjörð Bjarmason","brian m. carlson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"450506","messageId":"20220307033723.175553-2-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220307033723.175553-1-jason@jasonyundt.email","subject":"[PATCH 1/2] comment: fix typo","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-07T03:37:22Z","receivedAt":"2022-03-07T03:45:34Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Signed-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n t/t9502-gitweb-standalone-parse-output.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex 3167473b30..e7363511dd 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -34,7 +34,7 @@ EOF\n #\n # This will check that gitweb HTTP header contains proposed filename\n # as <basename> with '.tar' suffix added, and that generated tarfile\n-# (gitweb message body) has <prefix> as prefix for al files in tarfile\n+# (gitweb message body) has <prefix> as prefix for all files in tarfile\n #\n # <prefix> default to <basename>\n check_snapshot () {\n-- \n2.35.1\n\n"},{"id":"450507","messageId":"20220307033723.175553-1-jason@jasonyundt.email","threadId":"57513","inReplyTo":null,"subject":"[PATCH 0/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-07T03:37:21Z","receivedAt":"2022-03-07T03:45:36Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"See the second commit's message for more details.\n\nJason Yundt (2):\n  comment: fix typo\n  gitweb: remove invalid http-equiv=\"content-type\"\n\n gitweb/gitweb.perl                        |  4 +---\n t/t9502-gitweb-standalone-parse-output.sh | 15 ++++++++++++++-\n 2 files changed, 15 insertions(+), 4 deletions(-)\n\n-- \n2.35.1\n\n"},{"id":"450508","messageId":"20220307033723.175553-3-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220307033723.175553-1-jason@jasonyundt.email","subject":"[PATCH 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-07T03:37:23Z","receivedAt":"2022-03-07T03:46:00Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Before this change, gitweb would generate pages which included:\n\n\t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\"/>\n\nA meta element with http-equiv=\"content-type\" is said to be in the\n\"Encoding declaration state\". According to the HTML Standard,\n\n\tThe Encoding declaration state may be used in HTML documents,\n\tbut elements with an http-equiv attribute in that state must not\n\tbe used in XML documents.\n\n\tSource: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n\nThis change removes that meta element since gitweb always generates XML\ndocuments.\n\nSigned-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n gitweb/gitweb.perl                        |  4 +---\n t/t9502-gitweb-standalone-parse-output.sh | 13 +++++++++++++\n 2 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex fbd1c20a23..606b50104c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4213,8 +4213,7 @@ sub git_header_html {\n \tmy %opts = @_;\n \n \tmy $title = get_page_title();\n-\tmy $content_type = get_content_type_html();\n-\tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n+\tprint $cgi->header(-type=>get_content_type_html(), -charset => 'utf-8',\n \t                   -status=> $status, -expires => $expires)\n \t\tunless ($opts{'-no_http_header'});\n \tmy $mod_perl_version = $ENV{'MOD_PERL'} ? \" $ENV{'MOD_PERL'}\" : '';\n@@ -4225,7 +4224,6 @@ sub git_header_html {\n <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n <!-- git core binaries version $git_version -->\n <head>\n-<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex e7363511dd..25165edacc 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -207,4 +207,17 @@ test_expect_success 'xss checks' '\n \txss \"\" \"$TAG+\"\n '\n \n+no_http_equiv_content_type() {\n+\tgitweb_run \"$@\" &&\n+\t! grep -Ei \"http-equiv=['\\\"]?content-type\" gitweb.body\n+}\n+\n+# See: <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-http-equiv-content-type>\n+test_expect_success 'no http-equiv=\"content-type\" in XHTML' '\n+\tno_http_equiv_content_type &&\n+\tno_http_equiv_content_type \"p=.git\" &&\n+\tno_http_equiv_content_type \"p=.git;a=log\" &&\n+\tno_http_equiv_content_type \"p=.git;a=tree\"\n+'\n+\n test_done\n-- \n2.35.1\n\n"},{"id":"450537","messageId":"220307.861qze0wv9.gmgdl@evledraar.gmail.com","threadId":"57513","inReplyTo":"20220307033723.175553-3-jason@jasonyundt.email","subject":"Re: [PATCH 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-07T12:23:49Z","receivedAt":"2022-03-07T12:29:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Mar 06 2022, Jason Yundt wrote:\n\n> Before this change, gitweb would generate pages which included:\n>\n> \t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\"/>\n>\n> A meta element with http-equiv=\"content-type\" is said to be in the\n> \"Encoding declaration state\". According to the HTML Standard,\n>\n> \tThe Encoding declaration state may be used in HTML documents,\n> \tbut elements with an http-equiv attribute in that state must not\n> \tbe used in XML documents.\n>\n> \tSource: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n>\n> This change removes that meta element since gitweb always generates XML\n> documents.\n>\n> Signed-off-by: Jason Yundt <jason@jasonyundt.email>\n> ---\n>  gitweb/gitweb.perl                        |  4 +---\n>  t/t9502-gitweb-standalone-parse-output.sh | 13 +++++++++++++\n>  2 files changed, 14 insertions(+), 3 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index fbd1c20a23..606b50104c 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -4213,8 +4213,7 @@ sub git_header_html {\n>  \tmy %opts = @_;\n>  \n>  \tmy $title = get_page_title();\n> -\tmy $content_type = get_content_type_html();\n> -\tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n> +\tprint $cgi->header(-type=>get_content_type_html(), -charset => 'utf-8',\n\nI think it would be better to just skip this hunk, no behavior will\nchange if it's left in.\n\n>  \t                   -status=> $status, -expires => $expires)\n>  \t\tunless ($opts{'-no_http_header'});\n>  \tmy $mod_perl_version = $ENV{'MOD_PERL'} ? \" $ENV{'MOD_PERL'}\" : '';\n> @@ -4225,7 +4224,6 @@ sub git_header_html {\n>  <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n>  <!-- git core binaries version $git_version -->\n>  <head>\n> -<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n\n..with this being the only behavior change (yeah the variable will now\nbe used only in one place, but that's fine)\n\nI'm not sure I understand this change really. The result in always XML,\nso application/xhtml+xml is redundant, text/html, or both?\n\nBut aside from that: I have seen browsers get the lack of encoding=\"\"\n\"wrong\" with data at rest, don't some still default to ISO-8859-1?\n\nSo won't this result in badly decoded data if you save the web page &\nview it locally?\n\n>  <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n>  <meta name=\"robots\" content=\"index, nofollow\"/>\n>  <title>$title</title>\n> diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\n> index e7363511dd..25165edacc 100755\n> --- a/t/t9502-gitweb-standalone-parse-output.sh\n> +++ b/t/t9502-gitweb-standalone-parse-output.sh\n> @@ -207,4 +207,17 @@ test_expect_success 'xss checks' '\n>  \txss \"\" \"$TAG+\"\n>  '\n>  \n> +no_http_equiv_content_type() {\n> +\tgitweb_run \"$@\" &&\n> +\t! grep -Ei \"http-equiv=['\\\"]?content-type\" gitweb.body\n\nNit: Should we skip the \"-i\" here since we're testing our own output,\nand not http standards in general (i.e. we don't have to worry about the\ncase of http-equiv?)\n"},{"id":"450669","messageId":"109813056.nniJfEyVGO@jason-desktop-linux","threadId":"57513","inReplyTo":"220307.861qze0wv9.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-07T22:49:48Z","receivedAt":"2022-03-07T22:49:54Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"On Monday, March 7, 2022 7:23:49 AM EST Ævar Arnfjörð Bjarmason wrote:\n> I'm not sure I understand this change really. The result in always XML,\n> so application/xhtml+xml is redundant, text/html, or both?\n\nTo be honest, using an http-equiv=\"content-type\" in XHTML is confusing. When \nyou do use one, your goal shouldn’t really be to specify the document’s MIME \ntype. After all, the first three lines of each page say\n\n\t<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\t<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\t<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\" lang=\"en-US\">\n\nThose lines are more than enough to determine that something is using XHTML \nand UTF-8. Instead, the idea is to help out a parser that is incorrectly \nparsing the document as HTML (instead of as XHTML). Historical W3C documents  \n(that were applicable when http-equiv=\"content-type\" was allowed in XHTML) [1]\n[2][3] indicate that http-equiv=\"content-type\" should be used like this:\n\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n\nIn other words, to use http-equiv=\"content-type\" properly in XHTML, you had to \nlie about the document’s type. The fact that this is confusing is probably \npart of why WHATWG disallowed it in the HTML Standard.\n\n> But aside from that: I have seen browsers get the lack of encoding=\"\"\n> \"wrong\" with data at rest, don't some still default to ISO-8859-1?\n> \n> So won't this result in badly decoded data if you save the web page &\n> view it locally?\n\nI tested this idea in ungoogled-chromium, Firefox and Pale Moon. Other than \nPale Moon in one specific circumstance, they all used UTF-8 as the encoding. \nPale Moon used windows-1252, but only when the file ended with .html. When the \nfile ended with .xhtml, Pale Moon used UTF-8. That being said, we don’t have to \nuse an http-equiv=\"content-type\" to fix the problem. Instead, we can use a \n<meta charset=\"utf-8\"> which is allowed by the HTML Standard [4].\n\n[1]: <https://www.w3.org/TR/xhtml1/#C_9>\n[2]: <https://www.w3.org/TR/html-polyglot/#character-encoding>\n[3]: <https://www.w3.org/Bugs/Public/show_bug.cgi?id=21818>\n\n[4]: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset>\n\n\n\n"},{"id":"450671","messageId":"YiaUP3b3PJWZx+AY@camp.crustytoothpaste.net","threadId":"57513","inReplyTo":"20220307033723.175553-3-jason@jasonyundt.email","subject":"Re: [PATCH 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-03-07T23:24:47Z","receivedAt":"2022-03-07T23:24:53Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-03-07 at 03:37:23, Jason Yundt wrote:\n> Before this change, gitweb would generate pages which included:\n> \n> \t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\"/>\n> \n> A meta element with http-equiv=\"content-type\" is said to be in the\n> \"Encoding declaration state\". According to the HTML Standard,\n> \n> \tThe Encoding declaration state may be used in HTML documents,\n> \tbut elements with an http-equiv attribute in that state must not\n> \tbe used in XML documents.\n> \n> \tSource: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n> \n> This change removes that meta element since gitweb always generates XML\n> documents.\n\nThis change seems fine.  We do specify this in the HTTP header,\nincluding the character set, which is what matters, so this should work\nin every browser, and the http-equiv is unneeded.\n\nI also don't think we need a meta header here, since we have an XML\ndeclaration, and that's controlling in this situation.  This isn't\nregular HTML and we don't declare it as such, so using a meta header to\ncontrol this isn't correct: the XML declaration should be used instead\nin the event a user downloads this to a local disk and processes it\noutside the context of an HTTP request.\n\nSince we control the HTTP headers, I'd actually argue that your test\nmight well reject all http-equiv headers since they could be done much\nbetter with actual HTTP headers (and would therefore work with\nnon-browser clients), but I don't think that's worth a reroll, nor do I\nthink a test is even needed here (but bonus points for adding one).\n\nSo I think this looks good as is.  Thanks for the patch.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"450692","messageId":"20220308010711.61817-1-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220307033723.175553-1-jason@jasonyundt.email","subject":"[PATCH v2 0/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T01:07:09Z","receivedAt":"2022-03-08T01:08:34Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"See the second commit's message for more details. Compared to the first\nversion of this patch, this one\n\n- keeps an extra variable,\n- replaces the http-equiv=\"content-type\" tag with a charset= one, and\n- removes the -i flag from grep.\n\nJason Yundt (2):\n  comment: fix typo\n  gitweb: remove invalid http-equiv=\"content-type\"\n\n gitweb/gitweb.perl                        |  2 +-\n t/t9502-gitweb-standalone-parse-output.sh | 18 +++++++++++++++++-\n 2 files changed, 18 insertions(+), 2 deletions(-)\n\n-- \n2.35.1\n\n"},{"id":"450693","messageId":"20220308010711.61817-3-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220307033723.175553-1-jason@jasonyundt.email","subject":"[PATCH v2 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T01:07:11Z","receivedAt":"2022-03-08T01:08:36Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Before this change, gitweb would generate pages which included:\n\n\t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\"/>\n\nA meta element with http-equiv=\"content-type\" is said to be in the\n\"Encoding declaration state\". According to the HTML Standard,\n\n\tThe Encoding declaration state may be used in HTML documents,\n\tbut elements with an http-equiv attribute in that state must not\n\tbe used in XML documents.\n\n\tSource: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n\nGitweb always generates XML documents, so its use of\nhttp-equiv=\"content-type\" was invalid. This change replaces that tag\nwith\n\n\t<meta charset=\"utf-8\"/>\n\nwhich is equivalent [1] and allowed in XML documents [2].\n\n[1]: <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-http-equiv>\n[2]: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset>\n\nSigned-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n gitweb/gitweb.perl                        |  2 +-\n t/t9502-gitweb-standalone-parse-output.sh | 16 ++++++++++++++++\n 2 files changed, 17 insertions(+), 1 deletion(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex fbd1c20a23..59457c1004 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4225,7 +4225,7 @@ sub git_header_html {\n <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n <!-- git core binaries version $git_version -->\n <head>\n-<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n+<meta charset=\"utf-8\"/>\n <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex e7363511dd..0b06e2d6b0 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -207,4 +207,20 @@ test_expect_success 'xss checks' '\n \txss \"\" \"$TAG+\"\n '\n \n+check_encoding_meta_element() {\n+\tgitweb_run \"$@\" &&\n+\t! grep -E \"http-equiv=['\\\"]?content-type\" gitweb.body &&\n+\tgrep -F '<meta charset=\"utf-8\"/>' gitweb.body\n+}\n+\n+# One of those can be used in XHTML, the other one can't. See:\n+# <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-charset>\n+# <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-http-equiv-content-type>\n+test_expect_success 'no http-equiv=\"content-type\", yes charset=\"utf-8\"' '\n+\tcheck_encoding_meta_element &&\n+\tcheck_encoding_meta_element \"p=.git\" &&\n+\tcheck_encoding_meta_element \"p=.git;a=log\" &&\n+\tcheck_encoding_meta_element \"p=.git;a=tree\"\n+'\n+\n test_done\n-- \n2.35.1\n\n"},{"id":"450694","messageId":"20220308010711.61817-2-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220307033723.175553-1-jason@jasonyundt.email","subject":"[PATCH v2 1/2] comment: fix typo","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T01:07:10Z","receivedAt":"2022-03-08T01:08:56Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Signed-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n t/t9502-gitweb-standalone-parse-output.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex 3167473b30..e7363511dd 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -34,7 +34,7 @@ EOF\n #\n # This will check that gitweb HTTP header contains proposed filename\n # as <basename> with '.tar' suffix added, and that generated tarfile\n-# (gitweb message body) has <prefix> as prefix for al files in tarfile\n+# (gitweb message body) has <prefix> as prefix for all files in tarfile\n #\n # <prefix> default to <basename>\n check_snapshot () {\n-- \n2.35.1\n\n"},{"id":"450695","messageId":"Yia2Y2zoOjvVdJ9O@camp.crustytoothpaste.net","threadId":"57513","inReplyTo":"20220308010711.61817-3-jason@jasonyundt.email","subject":"Re: [PATCH v2 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-03-08T01:50:27Z","receivedAt":"2022-03-08T01:50:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-03-08 at 01:07:11, Jason Yundt wrote:\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index fbd1c20a23..59457c1004 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -4225,7 +4225,7 @@ sub git_header_html {\n>  <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n>  <!-- git core binaries version $git_version -->\n>  <head>\n> -<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n> +<meta charset=\"utf-8\"/>\n\nI don't actually think this is an improvement.  I don't think it's\nnecessary, considering we have an XML declaration and the HTTP header,\nboth of which already say it's UTF-8 and will take precedence over this.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"450697","messageId":"xmqqbkyhp4wv.fsf@gitster.g","threadId":"57513","inReplyTo":"20220308010711.61817-1-jason@jasonyundt.email","subject":"Re: [PATCH v2 0/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-03-08T02:13:52Z","receivedAt":"2022-03-08T02:13:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Yundt <jason@jasonyundt.email> writes:\n\n> - keeps an extra variable,\n\nI am not sure if this is an improvement.  The original had two\nplaces that used $content_type, but after getting rid of one, there\nis only one place that needed the value, which can be used in place;\nand it was quite clear that was what was going on in the previous\niteration.\n\nAbout the <meta> thing, it seems that brian already commented on it.\n\nThanks.\n\n\n"},{"id":"450725","messageId":"4386099.LvFx2qVVIh@jason-desktop-linux","threadId":"57513","inReplyTo":"xmqqbkyhp4wv.fsf@gitster.g","subject":"Re: [PATCH v2 0/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T12:26:51Z","receivedAt":"2022-03-08T12:27:27Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"On Monday, March 7, 2022 9:13:52 PM EST Junio C Hamano wrote:\n> About the <meta> thing, it seems that brian already commented on it.\n\nThanks for mentioning that. I now see Brian’s comments on the archive. My mail \nserver was blocking him (via zen.spamhaus.org), but I’ve added his server to \nthe allowlist.\n\n\n"},{"id":"450726","messageId":"220308.86cziwy595.gmgdl@evledraar.gmail.com","threadId":"57513","inReplyTo":"Yia2Y2zoOjvVdJ9O@camp.crustytoothpaste.net","subject":"Re: [PATCH v2 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-03-08T12:44:35Z","receivedAt":"2022-03-08T12:54:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Mar 08 2022, brian m. carlson wrote:\n\n> [[PGP Signed Part:Undecided]]\n> On 2022-03-08 at 01:07:11, Jason Yundt wrote:\n>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n>> index fbd1c20a23..59457c1004 100755\n>> --- a/gitweb/gitweb.perl\n>> +++ b/gitweb/gitweb.perl\n>> @@ -4225,7 +4225,7 @@ sub git_header_html {\n>>  <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n>>  <!-- git core binaries version $git_version -->\n>>  <head>\n>> -<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n>> +<meta charset=\"utf-8\"/>\n>\n> I don't actually think this is an improvement.  I don't think it's\n> necessary, considering we have an XML declaration and the HTTP header,\n> both of which already say it's UTF-8 and will take precedence over this.\n\nAgeed. I was a bit surprised per Jason's\nhttps://lore.kernel.org/git/109813056.nniJfEyVGO@jason-desktop-linux/\nthat the removal wasn't kept.\n\nI.e. he was replying to a question of mine asking whether we didn't need\nthis data at rest, e.g if you save the page. I didn't notice the \"<?xml\nversion...\" we emit, which seems to be enough.\n\nI.e. this seems to have always been redundant going back to c994d620cc8\n(v220, 2005-08-07), or rather, the character set part of it.\n\nMaybe I still don't understand this, but the commit message seems to me\nbe conflating whether we send the *right* http-equiv with whether we\nsend it at all, i.e. if the problem is that XML documents shouldn't be\ntext/html isn't this correct?:\n\t\n\tdiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n\tindex fbd1c20a232..c1c5af0b197 100755\n\t--- a/gitweb/gitweb.perl\n\t+++ b/gitweb/gitweb.perl\n\t@@ -4049,7 +4049,13 @@ sub get_page_title {\n\t \treturn $title;\n\t }\n\t \n\t+sub get_content_type_xml {\n\t+\treturn 'application/xhtml+xml';\n\t+}\n\t+\n\t sub get_content_type_html {\n\t+\tmy ($want_xml) = @_;\n\t+\n\t \t# require explicit support from the UA if we are to send the page as\n\t \t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n\t \t# we have to do this because MSIE sometimes globs '*/*', pretending to\n\t@@ -4057,7 +4063,7 @@ sub get_content_type_html {\n\t \tif (defined $cgi->http('HTTP_ACCEPT') &&\n\t \t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n\t \t    $cgi->Accept('application/xhtml+xml') != 0) {\n\t-\t\treturn 'application/xhtml+xml';\n\t+\t\treturn get_content_type_html();\n\t \t} else {\n\t \t\treturn 'text/html';\n\t \t}\n\t@@ -4214,6 +4220,7 @@ sub git_header_html {\n\t \n\t \tmy $title = get_page_title();\n\t \tmy $content_type = get_content_type_html();\n\t+\tmy $content_type_xml = get_content_type_html();\n\t \tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n\t \t                   -status=> $status, -expires => $expires)\n\t \t\tunless ($opts{'-no_http_header'});\n\t@@ -4225,7 +4232,7 @@ sub git_header_html {\n\t <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n\t <!-- git core binaries version $git_version -->\n\t <head>\n\t-<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n\t+<meta http-equiv=\"content-type\" content=\"$content_type_xml; charset=utf-8\"/>\n\t <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n\t <meta name=\"robots\" content=\"index, nofollow\"/>\n\t <title>$title</title>\n\nOf course we might then *also* decide that <meta http-equiv> in this\ncase isn't needed at all, but isn't that a seperate change?\n\nAnd won't conforming browsers treat application/xhtml+xml differently\nwhen the page is saved? A long time ago (Idid some web development)\nusing it would enable pedantic strictness in browsers, i.e. unclosed\ntags etc. would be a hard error, but I can't reproduce that locally in\neither Firefox or Chrome now (with just the gitweb output as-is with\nthat http-equiv tweaked).\n\nSo maybe it does nothing, or maybe it's just those browser...\n"},{"id":"450750","messageId":"4175455.ejJDZkT8p0@jason-desktop-linux","threadId":"57513","inReplyTo":"220308.86cziwy595.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T14:54:21Z","receivedAt":"2022-03-08T14:54:25Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"On Tuesday, March 8, 2022 7:44:35 AM EST Ævar Arnfjörð Bjarmason wrote:\n> Maybe I still don't understand this, but the commit message seems to me\n> be conflating whether we send the *right* http-equiv with whether we\n> send it at all,\n\nThe intent behind the commit message is to say that <meta\nhttp-equiv=\"content-type\" …> is never correct in XHTML.\n\n> i.e. if the problem is that XML documents shouldn't be\n> text/html isn't this correct?:\n> \t\n> \tdiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> \tindex fbd1c20a232..c1c5af0b197 100755\n> \t--- a/gitweb/gitweb.perl\n> \t+++ b/gitweb/gitweb.perl\n> \t@@ -4049,7 +4049,13 @@ sub get_page_title {\n> \t \treturn $title;\n> \t }\n> \t \n> \t+sub get_content_type_xml {\n> \t+\treturn 'application/xhtml+xml';\n> \t+}\n> \t+\n> \t sub get_content_type_html {\n> \t+\tmy ($want_xml) = @_;\n> \t+\n> \t \t# require explicit support from the UA if we are to send the page as\n> \t \t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n> \t \t# we have to do this because MSIE sometimes globs '*/*', pretending to\n> \t@@ -4057,7 +4063,7 @@ sub get_content_type_html {\n> \t \tif (defined $cgi->http('HTTP_ACCEPT') &&\n> \t \t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n> \t \t    $cgi->Accept('application/xhtml+xml') != 0) {\n> \t-\t\treturn 'application/xhtml+xml';\n> \t+\t\treturn get_content_type_html();\n\nI’m guessing that you meant to call get_content_type_xml() here.\n\n> \t \t} else {\n> \t \t\treturn 'text/html';\n> \t \t}\n> \t@@ -4214,6 +4220,7 @@ sub git_header_html {\n> \t \n> \t \tmy $title = get_page_title();\n> \t \tmy $content_type = get_content_type_html();\n> \t+\tmy $content_type_xml = get_content_type_html();\n\nI’m also guessing that you meant to call get_content_type_xml() here.\n\n> \t \tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n> \t \t                   -status=> $status, -expires => $expires)\n> \t \t\tunless ($opts{'-no_http_header'});\n> \t@@ -4225,7 +4232,7 @@ sub git_header_html {\n> \t <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n> \t <!-- git core binaries version $git_version -->\n> \t <head>\n> \t-<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n> \t+<meta http-equiv=\"content-type\" content=\"$content_type_xml; charset=utf-8\"/>\n> \t <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n> \t <meta name=\"robots\" content=\"index, nofollow\"/>\n> \t <title>$title</title>\n\nWith those assumptions in mind, I don’t think that your code is correct if\nthe problem is that XML documents shouldn't be text/html. Here’s why:\n\n1. XML documents shouldn’t contain http-equiv=\"content-type\" [1].\n2. When a meta’s http-equiv attribute equals content-type, then its content\n    attribute should equal “the literal string \"text/html;\", optionally\n    followed by any number of ASCII whitespace, followed by the literal\n    string \"charset=utf-8\".” [1]\n\n[1]: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n\n\n\n"},{"id":"450752","messageId":"20220308155612.105957-3-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220308155612.105957-1-jason@jasonyundt.email","subject":"[PATCH v3 2/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T15:56:12Z","receivedAt":"2022-03-08T15:58:24Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Before this change, gitweb would generate pages which included:\n\n\t<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\"/>\n\nWhen a meta's http-equiv equals \"content-type\", the http-equiv is said\nto be in the \"Encoding declaration state\". According to the HTML\nStandard,\n\n\tThe Encoding declaration state may be used in HTML documents,\n\tbut elements with an http-equiv attribute in that state must not\n\tbe used in XML documents.\n\n\tSource: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-content-type>\n\nThis change removes that meta element since gitweb always generates XML\ndocuments.\n\nSigned-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n gitweb/gitweb.perl                        |  4 +---\n t/t9502-gitweb-standalone-parse-output.sh | 13 +++++++++++++\n 2 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex fbd1c20a23..606b50104c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4213,8 +4213,7 @@ sub git_header_html {\n \tmy %opts = @_;\n \n \tmy $title = get_page_title();\n-\tmy $content_type = get_content_type_html();\n-\tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n+\tprint $cgi->header(-type=>get_content_type_html(), -charset => 'utf-8',\n \t                   -status=> $status, -expires => $expires)\n \t\tunless ($opts{'-no_http_header'});\n \tmy $mod_perl_version = $ENV{'MOD_PERL'} ? \" $ENV{'MOD_PERL'}\" : '';\n@@ -4225,7 +4224,6 @@ sub git_header_html {\n <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\\@vrfy.org>, Christian Gierke -->\n <!-- git core binaries version $git_version -->\n <head>\n-<meta http-equiv=\"content-type\" content=\"$content_type; charset=utf-8\"/>\n <meta name=\"generator\" content=\"gitweb/$version git/$git_version$mod_perl_version\"/>\n <meta name=\"robots\" content=\"index, nofollow\"/>\n <title>$title</title>\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex e7363511dd..8cb582f0e6 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -207,4 +207,17 @@ test_expect_success 'xss checks' '\n \txss \"\" \"$TAG+\"\n '\n \n+no_http_equiv_content_type() {\n+\tgitweb_run \"$@\" &&\n+\t! grep -E \"http-equiv=['\\\"]?content-type\" gitweb.body\n+}\n+\n+# See: <https://html.spec.whatwg.org/dev/semantics.html#attr-meta-http-equiv-content-type>\n+test_expect_success 'no http-equiv=\"content-type\" in XHTML' '\n+\tno_http_equiv_content_type &&\n+\tno_http_equiv_content_type \"p=.git\" &&\n+\tno_http_equiv_content_type \"p=.git;a=log\" &&\n+\tno_http_equiv_content_type \"p=.git;a=tree\"\n+'\n+\n test_done\n-- \n2.35.1\n\n"},{"id":"450753","messageId":"20220308155612.105957-1-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220308010711.61817-1-jason@jasonyundt.email","subject":"[PATCH v3 0/2] gitweb: remove invalid http-equiv=\"content-type\"","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T15:56:10Z","receivedAt":"2022-03-08T15:59:01Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"See the second commit's message for more details. Compared to the second\nversion of this patch, this one\n\n- removes the extra variable again,\n- doesn't include a <meta charset=\"utf-8\"/> and\n- corrects a technical error in the second commit’s message.\n\nJason Yundt (2):\n  comment: fix typo\n  gitweb: remove invalid http-equiv=\"content-type\"\n\n gitweb/gitweb.perl                        |  4 +---\n t/t9502-gitweb-standalone-parse-output.sh | 15 ++++++++++++++-\n 2 files changed, 15 insertions(+), 4 deletions(-)\n\n-- \n2.35.1\n\n"},{"id":"450754","messageId":"20220308155612.105957-2-jason@jasonyundt.email","threadId":"57513","inReplyTo":"20220308155612.105957-1-jason@jasonyundt.email","subject":"[PATCH v3 1/2] comment: fix typo","fromName":"Jason Yundt","fromEmail":"jason@jasonyundt.email","sentAt":"2022-03-08T15:56:11Z","receivedAt":"2022-03-08T15:59:02Z","isPatch":true,"sender":{"key":"jason@jasonyundt.email","avatar":"https://avatars.githubusercontent.com/u/5579359?v=4"},"body":"Signed-off-by: Jason Yundt <jason@jasonyundt.email>\n---\n t/t9502-gitweb-standalone-parse-output.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh\nindex 3167473b30..e7363511dd 100755\n--- a/t/t9502-gitweb-standalone-parse-output.sh\n+++ b/t/t9502-gitweb-standalone-parse-output.sh\n@@ -34,7 +34,7 @@ EOF\n #\n # This will check that gitweb HTTP header contains proposed filename\n # as <basename> with '.tar' suffix added, and that generated tarfile\n-# (gitweb message body) has <prefix> as prefix for al files in tarfile\n+# (gitweb message body) has <prefix> as prefix for all files in tarfile\n #\n # <prefix> default to <basename>\n check_snapshot () {\n-- \n2.35.1\n\n"}]}