Bug #17561
closedmeta http-equiv="Content-Type" should change along with config.doctype
0%
Description
When using config.doctype = xhtml_11 to specify that the content output is xhtml 1.1 a meta charset and ontent type tag is output that does not reflect this setting.
How to reproduce:
Set up a page as xhtml 1.1 and specify: config.doctype = xhtml_11
Expected result:
A meta tag saying:
<meta http-equiv="Content-Type" application/xhtml+xml; charset=utf-8"/>
Observed result:
A meta tag saying:
<meta http-equiv="Content-Type" text/html; charset=utf-8"/>
I propose to use an identical case stucture as is in use for the doctype switch itself.
I'm not a doctype guru, so I fixed this in our install for xhtml_11 only. The other meta tags are default.
(issue imported from #M6214)
Files
Updated by Michiel Roos about 17 years ago
Warning!
:-)
the provided diff is broken. . . I didn't read the message on http://juicystudio.com/article/content-negotiation.php carefully enough.
It clearly says: XHTML should be delivered as application/xhtml+xml. Most modern browsers, with the exception of Internet Explorer 6, support the MIME type application/xhtml+xml. This article demonstrates how to use content negotiation to deliver application/xhtml+xml to user agents that support that MIME type, and text/html to the rest.
This ammounts to: header("Vary: Accept");
if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml"))
header("Content-Type: application/xhtml+xml; charset=utf-8");
else
header("Content-Type: text/html; charset=utf-8");
This means that both the meta and the 'config.additionalHeaders' should be 'checked'.
$_SERVER[HTTP_ACCEPT] should be used to ensure that proper meta tags are sent to the right browsers.
NOTE HOWEVER!!!!!!!!!!
That in essence . . . the fact that some browsers are not able to handle application/xhtml+xml . . . means that we CANNOT use the meta tag with this definition at all . . . if we want to cache the page.
So as long as crappy browsers are around. We will not be able to serve valid xhtml. (correct me if I'm wrong.) The w3c accepts the page as 'valid', but still notes that there is a mismatch between doctype and content type (header and or meta).
What is the right approach here?
We cannot use: if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml")) when generating content that we want to cache . . .
It seems . . . that browsers still suck.
:-)
Updated by Michiel Roos about 17 years ago
It seems like TYPO3 is configured properly as it is. It may however be nice to add an esoteric option to 'force strict xhtml format'.
It would also be great if a comment were added in the code explaining the meta content-type setting. Preferably with links to online resources detailing the issue, like a wiki page or bug entry.
Updated by Martin Kutschker about 17 years ago
So what now? IMHO the meta tag can be ommited as modern browsers look only at the HTTP header. As you have noticed sending the "correct" header is not easy as not all browsers are up to date.
What's the advantage of sending application/xhtml+xml besides being very cool?
Updated by Michiel Roos about 17 years ago
Well . . . other than being very cool and compliant . . . none, as far as I can see now.
:-)
But . . . if you want to be very cool . . . the price you would pay would be that you cannot cache any page.
Updated by Thomas König almost 15 years ago
This problem is relevant again while switching to HTML5. I can already generate a valid HTML5-doctype but the charset-metatag is not rendered nicely for HTML5. It should be just be a simple »<meta charset="utf-8" />« instead of »<meta http-equiv="Content-Type" content="text/html; charset=utf-8">«. The long tag validates as well, and is not wrong, but the short one is prefered by W3C.
The related lines are 69 and 1123 in t3lib/class.t3lib_pagerenderer.php (TYPO3 V. 4.3).
There should be an option to give an own wrap for this tag, as in config.doctype.
Edit: As Michael wrote »ja_replacer« works fine. Another solution is the extension »html5meta_t3lib_pagerenderer« which generating the clean html charset-metatag.
Updated by Michiel Roos over 14 years ago
Hey Thomas,
I currently use an extension: ja_replacer to work around this issue. It rewrites the produced HTML according to a set of search replace rules you specify.
Maybe I'll try to write a patch agains the core when this starts to itch too much.
Updated by Sacha Vorbeck almost 14 years ago
I also support Thomas suggestion. The wrap defined in protected $metaCharsetTag should be made configurable. We are currently introducing HTML5 for government websites and therefore need the <meta charset="utf-8" /> option. Less code is economical.
Updated by Alexander Opitz over 11 years ago
- Status changed from New to Needs Feedback
- Target version deleted (
0) - TYPO3 Version set to 4.3
The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?
Updated by Riccardo De Contardi over 11 years ago
as this is a duplicated of #17534 and that issue is closed as resolved, I guess this can be closed as well
Updated by Alexander Opitz over 11 years ago
- Status changed from Needs Feedback to Closed