mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed ContentNegotiator to handle HTML and XHTML base tags properly when converting, regression from r108413 (from r108421)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112815 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a588ae305c
commit
fcc20b5e1a
@ -141,8 +141,8 @@ class ContentNegotiator {
|
|||||||
$response->addHeader("Vary" , "Accept");
|
$response->addHeader("Vary" , "Accept");
|
||||||
|
|
||||||
// Fix base tag
|
// Fix base tag
|
||||||
$content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\]><\/base><!\[endif\]-->/',
|
$content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\] \/><!\[endif\]-->/',
|
||||||
'<base href="$1"></base>', $content);
|
'<base href="$1" />', $content);
|
||||||
|
|
||||||
$content = str_replace(' ',' ', $content);
|
$content = str_replace(' ',' ', $content);
|
||||||
$content = str_replace('<br>','<br />', $content);
|
$content = str_replace('<br>','<br />', $content);
|
||||||
@ -170,7 +170,7 @@ class ContentNegotiator {
|
|||||||
$hasXMLHeader = (substr($content,0,5) == '<' . '?xml' );
|
$hasXMLHeader = (substr($content,0,5) == '<' . '?xml' );
|
||||||
|
|
||||||
// Fix base tag
|
// Fix base tag
|
||||||
$content = preg_replace('/<base href="([^"]*)"><\/base>/',
|
$content = preg_replace('/<base href="([^"]*)" \/>/',
|
||||||
'<base href="$1"><!--[if lte IE 6]></base><![endif]-->', $content);
|
'<base href="$1"><!--[if lte IE 6]></base><![endif]-->', $content);
|
||||||
|
|
||||||
$content = ereg_replace("<\\?xml[^>]+\\?>\n?",'',$content);
|
$content = ereg_replace("<\\?xml[^>]+\\?>\n?",'',$content);
|
||||||
|
@ -341,7 +341,7 @@ after')
|
|||||||
<head><% base_tag %></head>
|
<head><% base_tag %></head>
|
||||||
<body><p>test</p><body>
|
<body><p>test</p><body>
|
||||||
</html>';
|
</html>';
|
||||||
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $this->render($tmpl1));
|
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $this->render($tmpl1));
|
||||||
|
|
||||||
// HTML4 and 5 will only have it for IE
|
// HTML4 and 5 will only have it for IE
|
||||||
$tmpl2 = '<!DOCTYPE html>
|
$tmpl2 = '<!DOCTYPE html>
|
||||||
@ -368,7 +368,7 @@ after')
|
|||||||
|
|
||||||
$response = new SS_HTTPResponse($this->render($tmpl1));
|
$response = new SS_HTTPResponse($this->render($tmpl1));
|
||||||
$negotiator->xhtml($response);
|
$negotiator->xhtml($response);
|
||||||
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $response->getBody());
|
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user