]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: switch to an XHTML5 DOCTYPE
authorJason Yundt <redacted>
Thu, 2 Jun 2022 11:43:05 +0000 (07:43 -0400)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:33 +0000 (00:51 -0400)
According to the HTML Standard FAQ:

“What is the DOCTYPE for modern HTML documents?

In text/html documents:

<!DOCTYPE html>

In documents delivered with an XML media type: no DOCTYPE is required
and its use is generally unnecessary. However, you may use one if you
want (see the following question). Note that the above is well-formed
XML.”

Source: [1]

Gitweb uses an XHTML 1.0 DOCTYPE:

<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

While that DOCTYPE is still valid [2], it has several disadvantages:

1. It’s misleading. If an XML parser uses the DTD at the given link,
   then the entities &nbsp; and &sdot; won’t get declared. Instead, the
   parser has to use a DTD from the HTML Standard that has nothing to do
   with XHTML 1.0 [2].
2. It’s obsolete. XHTML 1.0 was last revised in 2002 and was superseded in
   2018 [3].
3. It’s unreliable. Gitweb uses &nbsp; and &sdot; but lets an external file
   define them. “[…U]using entity references for characters in XML documents
   is unsafe if they are defined in an external file (except for &lt;, &gt;,
   &amp;, &quot;, and &apos;).” [4]

[1]: <https://github.com/whatwg/html/blob/main/FAQ.md#what-is-the-doctype-for-modern-html-documents>
[2]: <https://html.spec.whatwg.org/multipage/xhtml.html#parsing-xhtml-documents>
[3]: <https://www.w3.org/TR/xhtml1/#xhtml>
[4]: <https://html.spec.whatwg.org/multipage/xhtml.html#writing-xhtml-documents>

Signed-off-by: Jason Yundt <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index ce2c48f8f521531f2c4687fa9ca39f4f7579fc79f80a482e6dbbb6a2e0ac46c3..5d5401f5ace7bdaa6d0bf59c7c8e52dd41f4dc869179d0dea76183727fbec7e2 100755 (executable)
@@ -4220,7 +4220,10 @@ sub git_header_html {
        my $mod_perl_version = $ENV{'MOD_PERL'} ? " $ENV{'MOD_PERL'}" : '';
        print <<EOF;
 <?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">
+<!DOCTYPE html [
+       <!ENTITY nbsp "&#xA0;">
+       <!ENTITY sdot "&#x22C5;">
+]>
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
 <!-- git web interface version $version, (C) 2005-2006, Kay Sievers <kay.sievers\@vrfy.org>, Christian Gierke -->
 <!-- git core binaries version $git_version -->
This page took 0.087578 seconds and 4 git commands to generate.