Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191541
Change subject: Show XFF header to the user in case of missig zero domain
......................................................................
Show XFF header to the user in case of missig zero domain
Whenever zero.wikipedia.org is not whitelisted for
the current carrier, we should show XFF header together with
the ip to make debugging easier.
Change-Id: I3f33169673080b6d6a7d8e4cafa4ace72d45a311
---
M includes/ZeroSpecialPage.php
1 file changed, 18 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner
refs/changes/41/191541/1
diff --git a/includes/ZeroSpecialPage.php b/includes/ZeroSpecialPage.php
index 0f9f431..f3efe8f 100644
--- a/includes/ZeroSpecialPage.php
+++ b/includes/ZeroSpecialPage.php
@@ -319,8 +319,8 @@
$host = implode( '.', $state->getWikiInfo() );
$bannerText = $this->msg( 'zero-sorry', $host )->text() . '<br
/>';
- $ip = $req->getIP();
- $bannerText .= $this->msg( 'zero-sorry-ip', $ip )->text() .
'<br />';
+ $ip = $this->getIpString();
+ $bannerText .= $this->msg( 'zero-sorry-ip', htmlspecialchars(
$ip ) )->text() . '<br />';
$url = false;
$from = $req->getVal( 'from' );
@@ -444,7 +444,7 @@
$host = implode( '.', $state->getWikiInfo() );
$bannerText = $this->msg( 'zero-sorry', $host
)->text() . "\n\n";
- $ip = $request->getIP();
+ $ip = $this->getIpString();
$bannerText .= $this->msg( 'zero-sorry-ip', $ip
)->text();
$banner = self::createImageBanner( 'red',
'white', $bannerText, true );
@@ -507,4 +507,19 @@
}
return $languageNames;
}
+
+ /**
+ * Get the IP string to be shown to the user
+ * Warning: the result is unsafe (user supplied)
+ * @return mixed
+ */
+ private function getIpString() {
+ $req = $this->getRequest();
+ $result = $req->getIP();
+ $xff = $req->getHeader( 'X-Forwarded-For' );
+ if ( $xff ) {
+ $result .= ' (' . $xff . ')';
+ }
+ return $result;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/191541
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f33169673080b6d6a7d8e4cafa4ace72d45a311
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroBanner
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits