r60506 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60505‎ | r60506 | r60507 >
Date:12:32, 30 December 2009
Author:ialex
Status:ok
Tags:
Comment:
Per Tim Starling, fixes for r58061:
* renamed $wgEnableSorbs to $wgEnableDnsBlacklist and $wgSorbsUrl to $wgDnsBlacklistUrls (backward compatibility kept)
* renamed User::inSorbsBlacklist() to User::isDnsBlacklisted()
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -1100,7 +1100,7 @@
11011101 * done against master.
11021102 */
11031103 function getBlockedStatus( $bFromSlave = true ) {
1104 - global $wgEnableSorbs, $wgProxyWhitelist, $wgUser;
 1104+ global $wgProxyWhitelist, $wgUser;
11051105
11061106 if ( -1 != $this->mBlockedby ) {
11071107 wfDebug( "User::getBlockedStatus: already loaded.\n" );
@@ -1168,8 +1168,8 @@
11691169 }
11701170
11711171 # DNSBL
1172 - if ( !$this->mBlockedby && $wgEnableSorbs && !$this->getID() ) {
1173 - if ( $this->inSorbsBlacklist( $ip ) ) {
 1172+ if ( !$this->mBlockedby && !$this->getID() ) {
 1173+ if ( $this->isDnsBlacklisted( $ip ) ) {
11741174 $this->mBlockedby = wfMsg( 'sorbs' );
11751175 $this->mBlockreason = wfMsg( 'sorbsreason' );
11761176 }
@@ -1183,16 +1183,24 @@
11841184 }
11851185
11861186 /**
1187 - * Whether the given IP is in the SORBS blacklist.
 1187+ * Whether the given IP is in a DNS blacklist.
11881188 *
11891189 * @param $ip \string IP to check
 1190+ * @param $checkWhitelist Boolean: whether to check the whitelist first
11901191 * @return \bool True if blacklisted.
11911192 */
1192 - function inSorbsBlacklist( $ip ) {
1193 - global $wgEnableSorbs, $wgSorbsUrl;
 1193+ function isDnsBlacklisted( $ip, $checkWhitelist = false ) {
 1194+ global $wgEnableSorbs, $wgEnableDnsBlacklist,
 1195+ $wgSorbsUrl, $wgDnsBlacklistUrls, $wgProxyWhitelist;
11941196
1195 - return $wgEnableSorbs &&
1196 - $this->inDnsBlacklist( $ip, $wgSorbsUrl );
 1197+ if ( !$wgEnableDnsBlacklist && !$wgEnableSorbs )
 1198+ return false;
 1199+
 1200+ if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) )
 1201+ return false;
 1202+
 1203+ $urls = array_merge( $wgDnsBlacklistUrls, (array)$wgSorbsUrl );
 1204+ return $this->inDnsBlacklist( $ip, $urls );
11971205 }
11981206
11991207 /**
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3494,16 +3494,30 @@
34953495 $wgEnableTooltipsAndAccesskeys = true;
34963496
34973497 /**
3498 - * Whether to use DNS blacklists in $wgSorbsUrl to check for open proxies
 3498+ * Whether to use DNS blacklists in $wgDnsBlacklistUrls to check for open proxies
 3499+ * @since 1.16
34993500 */
 3501+$wgEnableDnsBlacklist = false;
 3502+
 3503+/**
 3504+ * @deprecated Use $wgEnableDnsBlacklist instead, only kept for backward
 3505+ * compatibility
 3506+ */
35003507 $wgEnableSorbs = false;
35013508
35023509 /**
3503 - * List of DNS blacklists to use, if $wgEnableSorbs is true
 3510+ * List of DNS blacklists to use, if $wgEnableDnsBlacklist is true
 3511+ * @since 1.16
35043512 */
3505 -$wgSorbsUrl = array( 'http.dnsbl.sorbs.net.' );
 3513+$wgDnsBlacklistUrls = array( 'http.dnsbl.sorbs.net.' );
35063514
35073515 /**
 3516+ * @deprecated Use $wgDnsBlacklistUrls instead, only kept for backward
 3517+ * compatibility
 3518+ */
 3519+$wgSorbsUrl = array();
 3520+
 3521+/**
35083522 * Proxy whitelist, list of addresses that are assumed to be non-proxy despite
35093523 * what the other methods might say.
35103524 */
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -219,7 +219,6 @@
220220 */
221221 function addNewAccountInternal() {
222222 global $wgUser, $wgOut;
223 - global $wgEnableSorbs, $wgProxyWhitelist;
224223 global $wgMemc, $wgAccountCreationThrottle;
225224 global $wgAuth, $wgMinimalPasswordLength;
226225 global $wgEmailConfirmToEdit;
@@ -257,9 +256,7 @@
258257 }
259258
260259 $ip = wfGetIP();
261 - if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
262 - $wgUser->inSorbsBlacklist( $ip ) )
263 - {
 260+ if ( $wgUser->isDnsBlacklisted( $ip, true /* check $wgProxyWhitelist */ ) ) {
264261 $this->mainLoginForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
265262 return;
266263 }
Index: trunk/phase3/RELEASE-NOTES
@@ -68,7 +68,8 @@
6969 * $wgUploadMaintenance added to disable file deletions and restorations during
7070 maintenance
7171 * $wgCapitalLinkOverrides added to configure per-namespace capitalization
72 -* (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBL
 72+* (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBL and renamed
 73+ to $wgDnsBlacklistUrls (backward compatibility kept)
7374 * $wgEnableHtmlDiff has been removed
7475 * (bug 3340) $wgBlockCIDRLimit added (default: 16) to configure the low end of
7576 CIDR ranges for blocking
@@ -78,6 +79,8 @@
7980 * $wgDBAhandler added to choose a DBA handler when using CACHE_DBA
8081 * $wgPreviewOnOpenNamespaces for extensions that create namespaces that behave
8182 similarly to the category namespace.
 83+* $wgEnableSorbs renamed to $wgDnsBlacklistUrls ($wgEnableSorbs kept for
 84+ backward compatibility)
8285
8386 === New features in 1.16 ===
8487

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r58061* (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBLialex18:36, 23 October 2009

Status & tagging log