mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
92ab004781
commit
b4101984e4
@ -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);
|
||||||
|
@ -107,7 +107,7 @@ SS
|
|||||||
<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>/', $tmpl1->process(new ViewableData()));
|
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $tmpl1->process(new ViewableData()));
|
||||||
|
|
||||||
// HTML4 and 5 will only have it for IE
|
// HTML4 and 5 will only have it for IE
|
||||||
$tmpl2 = SSViewer::fromString('<!DOCTYPE html>
|
$tmpl2 = SSViewer::fromString('<!DOCTYPE html>
|
||||||
@ -134,7 +134,7 @@ SS
|
|||||||
|
|
||||||
$response = new SS_HTTPResponse($tmpl1->process(new ViewableData()));
|
$response = new SS_HTTPResponse($tmpl1->process(new ViewableData()));
|
||||||
$negotiator->xhtml($response);
|
$negotiator->xhtml($response);
|
||||||
$this->assertRegExp('/<head><base href=".*"><\/base><\/head>/', $response->getBody());
|
$this->assertRegExp('/<head><base href=".*" \/><\/head>/', $response->getBody());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user