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:
Sam Minnee 2010-10-19 01:20:07 +00:00
parent a588ae305c
commit fcc20b5e1a
2 changed files with 5 additions and 5 deletions

View File

@ -141,8 +141,8 @@ class ContentNegotiator {
$response->addHeader("Vary" , "Accept");
// Fix base tag
$content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\]><\/base><!\[endif\]-->/',
'<base href="$1"></base>', $content);
$content = preg_replace('/<base href="([^"]*)"><!--\[if[[^\]*]\] \/><!\[endif\]-->/',
'<base href="$1" />', $content);
$content = str_replace('&nbsp;','&#160;', $content);
$content = str_replace('<br>','<br />', $content);
@ -170,7 +170,7 @@ class ContentNegotiator {
$hasXMLHeader = (substr($content,0,5) == '<' . '?xml' );
// Fix base tag
$content = preg_replace('/<base href="([^"]*)"><\/base>/',
$content = preg_replace('/<base href="([^"]*)" \/>/',
'<base href="$1"><!--[if lte IE 6]></base><![endif]-->', $content);
$content = ereg_replace("<\\?xml[^>]+\\?>\n?",'',$content);

View File

@ -341,7 +341,7 @@ after')
<head><% base_tag %></head>
<body><p>test</p><body>
</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
$tmpl2 = '<!DOCTYPE html>
@ -368,7 +368,7 @@ after')
$response = new SS_HTTPResponse($this->render($tmpl1));
$negotiator->xhtml($response);
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $response->getBody());
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
}