From 4a9840e271eb6f4c713e6a4991571db390ea3d2b Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 20 Jan 2015 15:41:41 -0800 Subject: [PATCH] Add option to output referrer policy meta tag Bug: T87276 Change-Id: I9ea4797c4d292cd4565f47b88e605b4e7afdb1d1 --- includes/DefaultSettings.php | 10 ++++++++++ includes/OutputPage.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ee462d84ad..66f695c8d3 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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. diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a10946a4d1..4101d099f3 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 -- 2.20.1