Add option to output referrer policy meta tag
authorYuviPanda <yuvipanda@gmail.com>
Tue, 20 Jan 2015 23:41:41 +0000 (15:41 -0800)
committerYuviPanda <yuvipanda@gmail.com>
Wed, 21 Jan 2015 01:21:13 +0000 (17:21 -0800)
Bug: T87276
Change-Id: I9ea4797c4d292cd4565f47b88e605b4e7afdb1d1

includes/DefaultSettings.php
includes/OutputPage.php

index ee462d8..66f695c 100644 (file)
@@ -270,6 +270,16 @@ $wgFavicon = '/favicon.ico';
  */
 $wgAppleTouchIcon = false;
 
+/**
+ * Value for the referrer policy meta tag.
+ * One of 'never', 'default', 'origin', 'always'. Setting it to false just
+ * prevents the meta tag from being output.
+ * See http://www.w3.org/TR/referrer-policy/ for details.
+ *
+ * @since 1.25
+ */
+$wgReferrerPolicy = false;
+
 /**
  * The local filesystem path to a temporary directory. This is not required to
  * be web accessible.
index a10946a..4101d09 100644 (file)
@@ -3284,6 +3284,13 @@ class OutputPage extends ContextSource {
                        'content' => "MediaWiki $wgVersion",
                ) );
 
+               if ( $config->get( 'ReferrerPolicy' ) !== false ) {
+                       $tags['meta-referrer'] = Html::element( 'meta', array(
+                               'name' => 'referrer',
+                               'content' => $config->get( 'ReferrerPolicy' )
+                       ) );
+               }
+
                $p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
                if ( $p !== 'index,follow' ) {
                        // http://www.robotstxt.org/wc/meta-user.html