Project

General

Profile

Actions

Bug #17561

closed

meta http-equiv="Content-Type" should change along with config.doctype

Added by Michiel Roos over 16 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
-
Start date:
2007-08-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.3
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

fix.diff (1.68 KB) fix.diff Administrator Admin, 2007-08-27 13:31

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #58167: Meta-Tag http-equiv="Content-Type" content="text/html [...]"Closed2014-04-24

Actions
Has duplicate TYPO3 Core - Bug #17534: Meta-Tag http-equiv="Content-Type" content="text/html [...]"ClosedChristian Kuhn2007-08-15

Actions
Actions #1

Updated by Michiel Roos over 16 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.

:-)

Actions #2

Updated by Michiel Roos over 16 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.

Actions #3

Updated by Martin Kutschker over 16 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?

Actions #4

Updated by Michiel Roos over 16 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.

Actions #5

Updated by Thomas König about 14 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.

Actions #6

Updated by Michiel Roos about 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.

Actions #7

Updated by Sacha Vorbeck over 13 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.

Actions #8

Updated by Alexander Opitz almost 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)?

Actions #9

Updated by Riccardo De Contardi almost 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

Actions #10

Updated by Alexander Opitz almost 11 years ago

  • Status changed from Needs Feedback to Closed
Actions

Also available in: Atom PDF