Merge pull request #1256 from g4b0/xhtml-xml-schema-not-required-31

BUGFIX: Removed XHTML XML declaration requirement
This commit is contained in:
Ingo Schommer 2013-03-07 09:43:20 -08:00
commit d83950bc2b

View File

@ -135,24 +135,18 @@ class ContentNegotiator {
public function xhtml(SS_HTTPResponse $response) { public function xhtml(SS_HTTPResponse $response) {
$content = $response->getBody(); $content = $response->getBody();
// Only serve "pure" XHTML if the XML header is present $response->addHeader("Content-Type", "application/xhtml+xml; charset=" . self::$encoding);
if(substr($content,0,5) == '<' . '?xml' ) { $response->addHeader("Vary" , "Accept");
$response->addHeader("Content-Type", "application/xhtml+xml; charset=" . self::$encoding);
$response->addHeader("Vary" , "Accept");
// Fix base tag // Fix base tag
$content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\] \/><!\[endif\]-->/', $content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\] \/><!\[endif\]-->/',
'<base href="$1" />', $content); '<base href="$1" />', $content);
$content = str_replace('&nbsp;','&#160;', $content); $content = str_replace('&nbsp;','&#160;', $content);
$content = str_replace('<br>','<br />', $content); $content = str_replace('<br>','<br />', $content);
$content = preg_replace('#(<img[^>]*[^/>])>#i', '\\1/>', $content); $content = preg_replace('#(<img[^>]*[^/>])>#i', '\\1/>', $content);
$response->setBody($content); $response->setBody($content);
} else {
return $this->html($response);
}
} }
/* /*