git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] gitweb: remove invalid http-equiv="content-type"

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 7, 2022, 12:23 UTC
Message-ID
<220307.861qze0wv9.gmgdl@evledraar.gmail.com>
In-Reply-To
<20220307033723.175553-3-jason@jasonyundt.email>
On Sun, Mar 06 2022, Jason Yundt wrote:
Show 33 quoted lines
> Before this change, gitweb would generate pages which included:
>
> 	<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
>
> 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: <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>
> ---
>  gitweb/gitweb.perl                        |  4 +---
>  t/t9502-gitweb-standalone-parse-output.sh | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index fbd1c20a23..606b50104c 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -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',

I think it would be better to just skip this hunk, no behavior will change if it's left in.

Show 8 quoted lines
>  	                   -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"/>

..with this being the only behavior change (yeah the variable will now be used only in one place, but that's fine)

I'm not sure I understand this change really. The result in always XML, so application/xhtml+xml is redundant, text/html, or both?

But aside from that: I have seen browsers get the lack of encoding="" "wrong" with data at rest, don't some still default to ISO-8859-1?

So won't this result in badly decoded data if you save the web page & view it locally?

Show 14 quoted lines
>  <meta name="generator" content="gitweb/$version git/$git_version$mod_perl_version"/>
>  <meta name="robots" content="index, nofollow"/>
>  <title>$title</title>
> diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh
> index e7363511dd..25165edacc 100755
> --- a/t/t9502-gitweb-standalone-parse-output.sh
> +++ b/t/t9502-gitweb-standalone-parse-output.sh
> @@ -207,4 +207,17 @@ test_expect_success 'xss checks' '
>  	xss "" "$TAG+"
>  '
>  
> +no_http_equiv_content_type() {
> +	gitweb_run "$@" &&
> +	! grep -Ei "http-equiv=['\"]?content-type" gitweb.body
Nit: Should we skip the "-i" here since we're testing our own output,
and not http standards in general (i.e. we don't have to worry about the
case of http-equiv?)
Previous: Jason YundtNext: Jason Yundt
Message 4 of 17 in “gitweb: remove invalid http-equiv="content-type"”
  1. 0/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 7, 2022
  2. 1/2 comment: fix typoJason Yundt, Mar 7, 2022
  3. 2/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 7, 2022
  4. Ævar Arnfjörð BjarmasonMar 7, 2022
  5. Jason YundtMar 7, 2022
  6. brian m. carlsonMar 7, 2022
  7. 0/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 8, 2022
  8. Junio C HamanoMar 8, 2022
  9. Jason YundtMar 8, 2022
  10. 0/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 8, 2022
  11. 2/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 8, 2022
  12. 1/2 comment: fix typoJason Yundt, Mar 8, 2022
  13. 2/2 gitweb: remove invalid http-equiv="content-type"Jason Yundt, Mar 8, 2022
  14. brian m. carlsonMar 8, 2022
  15. Ævar Arnfjörð BjarmasonMar 8, 2022
  16. Jason YundtMar 8, 2022
  17. 1/2 comment: fix typoJason Yundt, Mar 8, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.