#8159 closed enhancement (maybelater)
Trac pages claim XHTML, render as HTML5
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Component: | Trac | Keywords: | |
| Cc: |
Description
Trac pages start with XHTML DOCTYPE and xmlns attributes:
<!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">
However, the pages are not XHTML pages. They are HTML5 (in no-quirks mode). This is likely due to the Content-type: text/html HTTP header.
It would be nice to remove the misleading XHTML parts and start the document as normative HTML5:
<!DOCTYPE html> <html>
I have confirmed this behavior on
This can be verified in a few ways:
Modify request headers to use Content-type: application/xhtml+xml;charset=utf-8. Chrome shows several errors on Trac changesets in this case.
Without modifying headers, you can verify that the document is _not_ XHTML. In an XHTML document, this will error:
document.body.innerHTML += "<meta name='xml-must-self-close'>"
Uncaught SyntaxError: Failed to set the 'innerHTML' property on 'Element': The provided markup is invalid XML, and therefore cannot be inserted into an XML document.
Finally, this snippet can indicate whether the document is in no-quirks, limited-quirks, or quirks mode. (document.compatMode will not distinguish between limited-quirks and no-quirks):
document.body.innerHTML = `
<style>
p > table { background-color: red; height: 10px; width: 10px }
td { background-color: orange; }
</style>
<ul>
<li>In quirks and limited-quirks, this table is composed of square cells.
<li>In quirks mode, it will have a red background (because <code>P > TABLE</code> is allowed).
<li>In no-quirks mode, the cells become tall rectangles.
</ul>
<p><table>
<td><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='blue'/%3E%3C/svg%3E">
<td><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='blue'/%3E%3C/svg%3E">
<tr>
<td><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='blue'/%3E%3C/svg%3E">
<td><img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Crect width='10' height='10' fill='blue'/%3E%3C/svg%3E">
</table>
</p>
`
Change History (8)
#2
follow-up:
↓ 3
@
6 weeks ago
- Resolution set to maybelater
- Status changed from new to closed
- Type changed from defect (bug) to enhancement
We generally don't mess with the trac systems unless we need to fix something specifically. Currently the render mode doesn't really matter. The doctype header doesn't matter really at all. Changing around the trac theme just in order to change this seems unlikely to happen anytime soon, unless we need to fix something else in the theme anyway.
So for now I'm going to close this as maybe later. But, we may revisit it if we need to alter something important in trac.
#3
in reply to:
↑ 2
@
6 weeks ago
Replying to Otto42:
We generally don't mess with the trac systems unless we need to fix something specifically. Currently the render mode doesn't really matter. The doctype header doesn't matter really at all. Changing around the trac theme just in order to change this seems unlikely to happen anytime soon, unless we need to fix something else in the theme anyway.
So for now I'm going to close this as maybe later. But, we may revisit it if we need to alter something important in trac.
Understood.
It's worth mentioning that this isn't just pedantic. I noticed it because of a warning when I tried to parse the document with PHP's \Dom\HTMLDocument:
<?php $ch = curl_init( 'https://core.trac.wordpress.org/changeset/61477' ); curl_setopt( $ch, CURLOPT_USERAGENT, 'test/0.1' ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); $html = curl_exec($ch); $doc = \Dom\HTMLDocument::createFromString( $html );
Warning: Dom\HTMLDocument::createFromString(): tree error bad-doctype-token-in-initial-mode in Entity, line: 1, column: 3-9 in …
#4
@
6 weeks ago
- Component changed from General to Trac
- Resolution maybelater deleted
- Status changed from closed to reopened
I think I'd like to tackle this, as it's something that's caused some warnings for me on other projects - That I'd not realised the source of :)
@jonsurrell FWIW You might be better off using the CSV or RSS trac options for whatever your parsing need is.
#6
follow-up:
↓ 7
@
6 weeks ago
- Resolution set to maybelater
- Status changed from accepted to closed
As it turns out, this isn't really possible, as Trac Genshi templates we're using are XHTML based.
Later trac versions (1.5+) use Jinja templates which are HTML based it seems.
Modify request headers to use Content-type: application/xhtml+xml;charset=utf-8. Chrome shows several errors on Trac changesets in this case.
My historic knowledge says this will cause browsers to use a strict XML parser, rather than a vague HTML parser.
Looking at our templates, I can remove 'xmlns="http://www.w3.org/1999/xhtml"' from them, but Genshi shoves them back in. We don't define a XHTML Doctype either, it's either not-specified or HTML5-style. https://meta.trac.wordpress.org/browser/sites/trunk/trac.wordpress.org/templates
I'm reclosing as maybelater. This will happen when we migrate to a newer version of Trac & newer templates.
#7
in reply to:
↑ 6
@
6 weeks ago
Replying to dd32:
You might be better off using the CSV or RSS trac options for whatever your parsing need is.
I'm using the CSV for tickets, but haven't found a similar option for changesets (aside from reading the whole RSS, which isn't really suitable for a specific changeset lookup). I'd love to know if it exists!
Replying to dd32:
Modify request headers to use Content-type: application/xhtml+xml;charset=utf-8. Chrome shows several errors on Trac changesets in this case.
My historic knowledge says this will cause browsers to use a strict XML parser, rather than a vague HTML parser.
Exactly, the DOCTYPE is for XHTML 1.0 which is the XML flavor of HTML4:
XHTML documents are XML conforming. As such, they are readily viewed, edited, and validated with standard XML tools.
XHTML support in WordPress is starting to go away. I researched this because I was concerned that changes coming in WordPress 7.0 could break some Trac page. Fortunately the pages are served as HTML5 so there's no issue.
#8
@
6 weeks ago
I'm using the CSV for tickets, but haven't found a similar option for changesets (aside from reading the whole RSS, which isn't really suitable for a specific changeset lookup). I'd love to know if it exists!
Ahh.. Looks like we're using svnlook for the Trac bot.. https://meta.trac.wordpress.org/browser/sites/trunk/common/includes/slack/trac/commit-handler.php
RSS is available, you can query for a specific revision by setting limit=1.
https://core.trac.wordpress.org/log/?format=rss&rev=61000&limit=1
Aha, The changelog format is even better, once you spot the hidden verbose flag:
https://core.trac.wordpress.org/log/?format=changelog&rev=61000&limit=1&verbose=on
Related: https://core.trac.wordpress.org/ticket/59883