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
Jason Yundt <jason@jasonyundt.email>
Date
Mar 7, 2022, 22:49 UTC
Message-ID
<109813056.nniJfEyVGO@jason-desktop-linux>
In-Reply-To
<220307.861qze0wv9.gmgdl@evledraar.gmail.com>
On Monday, March 7, 2022 7:23:49 AM EST Ævar Arnfjörð Bjarmason wrote:
> I'm not sure I understand this change really. The result in always XML,
> so application/xhtml+xml is redundant, text/html, or both?

To be honest, using an http-equiv="content-type" in XHTML is confusing. When you do use one, your goal shouldn’t really be to specify the document’s MIME type. After all, the first three lines of each page say

	<?xml version="1.0" encoding="utf-8"?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">

Those lines are more than enough to determine that something is using XHTML and UTF-8. Instead, the idea is to help out a parser that is incorrectly parsing the document as HTML (instead of as XHTML). Historical W3C documents (that were applicable when http-equiv="content-type" was allowed in XHTML) [1] [2][3] indicate that http-equiv="content-type" should be used like this:

	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

In other words, to use http-equiv="content-type" properly in XHTML, you had to lie about the document’s type. The fact that this is confusing is probably part of why WHATWG disallowed it in the HTML Standard.

Show 5 quoted lines
> 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?

I tested this idea in ungoogled-chromium, Firefox and Pale Moon. Other than Pale Moon in one specific circumstance, they all used UTF-8 as the encoding. Pale Moon used windows-1252, but only when the file ended with .html. When the file ended with .xhtml, Pale Moon used UTF-8. That being said, we don’t have to use an http-equiv="content-type" to fix the problem. Instead, we can use a <meta charset="utf-8"> which is allowed by the HTML Standard [4].

[1]: <https://www.w3.org/TR/xhtml1/#C_9> [2]: <https://www.w3.org/TR/html-polyglot/#character-encoding> [3]: <https://www.w3.org/Bugs/Public/show_bug.cgi?id=21818>

[4]: <https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-charset>
Previous: Ævar Arnfjörð BjarmasonNext: brian m. carlson
Message 5 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.