WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 3 months ago

#25863 new defect (bug)

Core not working when served as application/xhtml+xml

Reported by: pnutus Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.3
Component: General Keywords: has-patch
Focuses: template Cc:

Description

All pages in Core has the following first lines:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

The Doctype implies HTML5, but the xmlns attribute implies XHTML. The server I'm deploying on is interpreting the file as XHTML and serving it as application/xhtml+xml. Some Core pages contain named entities such as &nbsp;, which do not work when the page is served as application/xhtml+xml (at least not in WebKit/Blink browsers).

What is the point of the xmlns attribute, as it is deprecated in HTML5? Should we remove it?

Or change the named entities to numeric? related: #13341 #9030

Attachments (1)

ticket-25863-xmlns-removal.patch (7.7 KB) - added by bpetty 5 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 bpetty5 months ago

Related (for bundled themes): #14226
Also see: #18202 (HTML5 doctype for core)

It's not deprecated, but it is supposed to be irrelevant to HTML documents (as far as I understand it). However, I could see how some servers might interpret this as xhtml+xml since this is how you're supposed to define polyglot markup now, which is implied to be XHTML.

Note that #14226 points out that this could affect use of MathML and SVG. But I generally still agree with @nacin that as a CMS, WordPress shouldn't even be trying to support XHTML.

I'm fairly certain we should remove it (and will have a patch for it in a bit), but it should also be possible to prevent your server configuration from assuming it's XHTML, and serving it as application/xhtml+xml (WordPress is not responsible for this). What is your server running?

comment:2 bpetty5 months ago

  • Cc bpetty added
  • Keywords has-patch added

comment:3 SergeyBiryukov5 months ago

  • Keywords has-patch removed
  • Version changed from 3.7.1 to 3.3

We moved to <!DOCTYPE html> in #18202, so 3.3 is the earliest applicable version here.

Some previous discussions on application/xhtml+xml: #14224, #14225, #14226, #14363, #17453.

comment:4 SergeyBiryukov5 months ago

  • Keywords has-patch added

comment:5 pnutus5 months ago

My server is some kind of custom solution, and the administrator is reluctant to change the server configuration. So right now I have no choice but to remove xmlns manually.

I just thought I might contribute, and that it hopefully could be fixed upstream :)

Last edited 5 months ago by pnutus (previous) (diff)

comment:6 pnutus5 months ago

Do you know if I could put anything in my .htaccess file to make apache serve all php files as text/html as an interim solution? I have tried AddType text/html .php, but then it just stops evaluating the php code.

comment:7 bpetty5 months ago

You should look into your default_mimetype PHP INI setting. Since this is Apache, you might have override for PHP ini settings. Try this:

php_value default_mimetype text/html

comment:8 nacin3 months ago

  • Component changed from Validation to Template

I could go for ticket-25863-xmlns-removal.patch, though I am not particularly familiar with the ramifications of it.

comment:9 nacin3 months ago

  • Component changed from Template to General
  • Focuses template added
Note: See TracTickets for help on using tickets.