BUGFIX Fixed ContentNegotiator to handle HTML and XHTML base tags properly when converting, regression from r108413

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@108421 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-07-23 04:38:01 +00:00 committed by Sam Minnee
parent 92ab004781
commit b4101984e4
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

@ -107,7 +107,7 @@ SS
<head><% base_tag %></head>
<body><p>test</p><body>
</html>');
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $tmpl1->process(new ViewableData()));
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $tmpl1->process(new ViewableData()));
// HTML4 and 5 will only have it for IE
$tmpl2 = SSViewer::fromString('<!DOCTYPE html>
@ -134,7 +134,7 @@ SS
$response = new SS_HTTPResponse($tmpl1->process(new ViewableData()));
$negotiator->xhtml($response);
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $response->getBody());
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
}
}