MyBB Community Forums

Full Version: Serve application/xhtml+xml for Firefox etc.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my opinion a browser should get the most appropriate content and if it accepts application/xhtml+xml, all pages should have that content type (as suggested here: http://www.w3.org/TR/xhtml-media-types/)
Quote:In summary, 'application/xhtml+xml' SHOULD be used for XHTML Family documents,...

I personally use the following snippet to check whether or not the browser accepts application/xhtml+xml and send the appropriate header.
if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
  if(isset($_SERVER['HTTP_ACCEPT']) && preg_match('|application/xhtml\+xml(?!\s*;\s*q=0)|', $_SERVER['HTTP_ACCEPT'])) {
  	header('Content-Type: application/xhtml+xml; charset=utf-8');
  } else {
  	header('Content-Type: text/html; charset=utf-8');
  }

  header('Vary: Accept');
} else {
	header('Content-Type: text/html; charset=utf-8');
}

Furthermore the current content type needs to be inserted dynamically in the meta tag, as you are doing already with the charset.
Where do you add that code?
We don't serve up xml content unless it's an xml feed, which is defined as so already. So, what's the point?
@Tikitiki:
See template 'htmldoctype':
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

All files are using the XHTML DTD, which is an XML file!
Thus all files should be served as application/xhtml+xml when the browser explicitly requests it (e.g. IE doesn't and won't render the page correctly).
As I already quoted in my first post, the W3 Consortium also says that.

@laie_techie:
Roughly I did the following:
Modify the meta tag 'Content-Type' in template 'headerinclude':
<meta http-equiv="Content-Type" content="{$contenttype}; charset={$charset}" />

Then I modified the UTF8-Header Plugin:
function utf8_header() {
	global $contenttype;
	
	$contenttype = 'text/html';
	if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
	  if(isset($_SERVER['HTTP_ACCEPT']) && preg_match('|application/xhtml\+xml(?!\s*;\s*q=0)|', $_SERVER['HTTP_ACCEPT'])) {
	  	$contenttype = 'application/xhtml+xml';
	  	header('Content-Type: application/xhtml+xml; charset=utf-8');
	  } else {
	  	header('Content-Type: text/html; charset=utf-8');
	  }
	
	  header('Vary: Accept');
	} else {
		header('Content-Type: text/html; charset=utf-8');
	}	
}

Unfortunately, MyBB has a lot of invalid HTML code, which will render for example the Admin-CP useless unless you fix the code yourself (as the Admin-CP does not use templates...).
We barely have any invalid HTML code and the new ACP in 1.4 will be XHTML 1.0 valid

I'll talk to chris about your content-type changes
hoep you can deal with you problem now~
The problem with application/xhtml+xml is that it will show up a "XML Parsing Error: not well-formed" error if you make a little mistake (add <p><b></p></b> for example). Not the best example but anyways.

I believe we would get a lot more bug reports because of people not being able to code proper XHTML. I know, people should make proper XHTML code but not everybody do.

application/xhtml+xml parses differently aswell - so the style would be different.
Also we don't serve it as xml anyways as we don't have the <?xml ?> tag.