Merge b21afe6f85
into 5f12606447
This commit is contained in:
commit
52d04b93db
|
@ -228,13 +228,6 @@ class ContentNegotiator
|
|||
$content = $response->getBody();
|
||||
$hasXMLHeader = (substr($content ?? '', 0, 5) == '<' . '?xml');
|
||||
|
||||
// Fix base tag
|
||||
$content = preg_replace(
|
||||
'/<base href="([^"]*)" \/>/',
|
||||
'<base href="$1"><!--[if lte IE 6]></base><![endif]-->',
|
||||
$content ?? ''
|
||||
);
|
||||
|
||||
$content = preg_replace("#<\\?xml[^>]+\\?>\n?#", '', $content ?? '');
|
||||
$content = str_replace(
|
||||
['/>', 'xml:lang', 'application/xhtml+xml'],
|
||||
|
|
|
@ -854,13 +854,6 @@ PHP;
|
|||
*/
|
||||
public static function get_base_tag($contentGeneratedSoFar)
|
||||
{
|
||||
$base = Director::absoluteBaseURL();
|
||||
|
||||
// Is the document XHTML?
|
||||
if (preg_match('/<!DOCTYPE[^>]+xhtml/i', $contentGeneratedSoFar ?? '')) {
|
||||
return "<base href=\"$base\" />";
|
||||
} else {
|
||||
return "<base href=\"$base\"><!--[if lte IE 6]></base><![endif]-->";
|
||||
}
|
||||
return '<base href="' . Director::absoluteBaseURL() . '" />';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -962,35 +962,13 @@ after'
|
|||
</html>';
|
||||
$this->assertMatchesRegularExpression('/<head><base href=".*" \/><\/head>/', $this->render($tmpl1));
|
||||
|
||||
// HTML4 and 5 will only have it for IE
|
||||
$tmpl2 = '<!DOCTYPE html>
|
||||
<html>
|
||||
<head><% base_tag %></head>
|
||||
<body><p>test</p><body>
|
||||
</html>';
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/<head><base href=".*"><!--\[if lte IE 6\]><\/base><!\[endif\]--><\/head>/',
|
||||
$this->render($tmpl2)
|
||||
);
|
||||
|
||||
|
||||
$tmpl3 = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head><% base_tag %></head>
|
||||
<body><p>test</p><body>
|
||||
</html>';
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/<head><base href=".*"><!--\[if lte IE 6\]><\/base><!\[endif\]--><\/head>/',
|
||||
$this->render($tmpl3)
|
||||
);
|
||||
|
||||
// Check that the content negotiator converts to the equally legal formats
|
||||
$negotiator = new ContentNegotiator();
|
||||
|
||||
$response = new HTTPResponse($this->render($tmpl1));
|
||||
$negotiator->html($response);
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/<head><base href=".*"><!--\[if lte IE 6\]><\/base><!\[endif\]--><\/head>/',
|
||||
'/<head><base href=".*" \/><\/head>/',
|
||||
$response->getBody()
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue