mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Do not send the header if it is not defined
This commit is contained in:
parent
cb2dcc75f1
commit
2f6f5b5eff
@ -336,8 +336,10 @@ class Security extends Controller implements TemplateGlobalProvider {
|
||||
$this->getResponse()->addHeader('X-Frame-Options', $this->config()->frame_options);
|
||||
|
||||
// Prevent search engines from indexing the login page
|
||||
if ($this->config()->robots_tag) {
|
||||
$this->getResponse()->addHeader('X-Robots-Tag', $this->config()->robots_tag);
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
return $this->httpError(404); // no-op
|
||||
|
@ -581,6 +581,13 @@ class SecurityTest extends FunctionalTest {
|
||||
$this->assertContains('noindex', $robotsHeader);
|
||||
}
|
||||
|
||||
public function testDoNotSendEmptyRobotsHeaderIfNotDefined() {
|
||||
Config::inst()->update('Security', 'robots_tag', null);
|
||||
$response = $this->get(Config::inst()->get('Security', 'login_url'));
|
||||
$robotsHeader = $response->getHeader('X-Robots-Tag');
|
||||
$this->assertNull($robotsHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a log-in form using Director::test().
|
||||
* Helper method for the tests above
|
||||
|
Loading…
x
Reference in New Issue
Block a user