Fix robots "noindex, nofollow" signals
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
a29c866292
commit
b7060be18d
|
@ -239,6 +239,7 @@ class Response {
|
||||||
|
|
||||||
$this->headers['Content-Security-Policy'] = $this->getContentSecurityPolicy()->buildPolicy();
|
$this->headers['Content-Security-Policy'] = $this->getContentSecurityPolicy()->buildPolicy();
|
||||||
$this->headers['Feature-Policy'] = $this->getFeaturePolicy()->buildPolicy();
|
$this->headers['Feature-Policy'] = $this->getFeaturePolicy()->buildPolicy();
|
||||||
|
$this->headers['X-Robots-Tag'] = 'none';
|
||||||
|
|
||||||
if ($this->ETag) {
|
if ($this->ETag) {
|
||||||
$mergeWith['ETag'] = '"' . $this->ETag . '"';
|
$mergeWith['ETag'] = '"' . $this->ETag . '"';
|
||||||
|
|
|
@ -157,6 +157,7 @@ class TemplateResponse extends Response {
|
||||||
// \OCP\Template needs an empty string instead of 'blank' for an unwrapped response
|
// \OCP\Template needs an empty string instead of 'blank' for an unwrapped response
|
||||||
$renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs;
|
$renderAs = $this->renderAs === 'blank' ? '' : $this->renderAs;
|
||||||
|
|
||||||
|
\OCP\Util::addHeader('meta', ['name' => 'robots', 'content' => 'noindex, nofollow']);
|
||||||
$template = new \OCP\Template($this->appName, $this->templateName, $renderAs);
|
$template = new \OCP\Template($this->appName, $this->templateName, $renderAs);
|
||||||
|
|
||||||
foreach ($this->params as $key => $value) {
|
foreach ($this->params as $key => $value) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ class ControllerTest extends \Test\TestCase {
|
||||||
$this->controller = new ChildController($this->app, $request);
|
$this->controller = new ChildController($this->app, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testFormatResonseInvalidFormat() {
|
public function testFormatResonseInvalidFormat() {
|
||||||
$this->expectException(\DomainException::class);
|
$this->expectException(\DomainException::class);
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ class ControllerTest extends \Test\TestCase {
|
||||||
'Content-Type' => 'application/json; charset=utf-8',
|
'Content-Type' => 'application/json; charset=utf-8',
|
||||||
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
|
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
|
||||||
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
|
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
|
||||||
|
'X-Robots-Tag' => 'none',
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->controller->customDataResponse(['hi']);
|
$response = $this->controller->customDataResponse(['hi']);
|
||||||
|
|
|
@ -67,6 +67,7 @@ class DataResponseTest extends \Test\TestCase {
|
||||||
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
||||||
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
|
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self'",
|
||||||
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
|
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
|
||||||
|
'X-Robots-Tag' => 'none',
|
||||||
];
|
];
|
||||||
$expectedHeaders = array_merge($expectedHeaders, $headers);
|
$expectedHeaders = array_merge($expectedHeaders, $headers);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ class ResponseTest extends \Test\TestCase {
|
||||||
$expected = [
|
$expected = [
|
||||||
'Last-Modified' => 1,
|
'Last-Modified' => 1,
|
||||||
'ETag' => 3,
|
'ETag' => 3,
|
||||||
'Something-Else' => 'hi'
|
'Something-Else' => 'hi',
|
||||||
|
'X-Robots-Tag' => 'none',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->childResponse->setHeaders($expected);
|
$this->childResponse->setHeaders($expected);
|
||||||
|
@ -90,7 +91,7 @@ class ResponseTest extends \Test\TestCase {
|
||||||
public function testAddHeaderValueNullDeletesIt() {
|
public function testAddHeaderValueNullDeletesIt() {
|
||||||
$this->childResponse->addHeader('hello', 'world');
|
$this->childResponse->addHeader('hello', 'world');
|
||||||
$this->childResponse->addHeader('hello', null);
|
$this->childResponse->addHeader('hello', null);
|
||||||
$this->assertEquals(3, count($this->childResponse->getHeaders()));
|
$this->assertEquals(4, count($this->childResponse->getHeaders()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue