global $ceAllowConfirmedEmail;
$ceAllowConfirmedEmail = false;
+/**
+ * Regex to whitelist URLs to known-good sites...
+ * For instance:
+ * $wgCaptchaWhitelist = '#^https?://([a-z0-9-]+\\.)?(wikimedia|wikipedia)\.org/#i';
+ */
+$wgCaptchaWhitelist = false;
+
/**
* Set up message strings for captcha utilities.
*/
$oldLinks = $this->findLinks( $oldtext );
$newLinks = $this->findLinks( $newtext );
+ $unknownLinks = array_filter( $newLinks, array( &$this, 'filterLink' ) );
- $addedLinks = array_diff( $newLinks, $oldLinks );
+ $addedLinks = array_diff( $unknownLinks, $oldLinks );
$numLinks = count( $addedLinks );
if( $numLinks > 0 ) {
return false;
}
+ /**
+ * Filter callback function for URL whitelisting
+ * @return bool true if unknown, false if whitelisted
+ * @access private
+ */
+ function filterLink( $url ) {
+ global $wgCaptchaWhitelist;
+ return !( $wgCaptchaWhitelist && preg_match( $wgCaptchaWhitelist, $url ) );
+ }
+
/**
* The main callback run on edit attempts.
* @param EditPage $editPage