From: Roan Kattouw Date: Thu, 24 Jan 2008 21:42:21 +0000 (+0000) Subject: ConfirmEdit: Cleaning up brain-damaged implementation of keyMatch() which expected... X-Git-Url: https://git.toastfreeware.priv.at/toast/cookiecaptcha.git/commitdiff_plain/ae8beb8dd5288284acc570a9ad4aa7a98cf1fd9b?ds=inline ConfirmEdit: Cleaning up brain-damaged implementation of keyMatch() which expected $wgRequest as an argument only to call $wgRequest->getVal('wpCaptchaWord') and do nothing else with it --- diff --git a/ConfirmEdit_body.php b/ConfirmEdit_body.php index a9600d7..1755183 100644 --- a/ConfirmEdit_body.php +++ b/ConfirmEdit_body.php @@ -206,12 +206,12 @@ class SimpleCaptcha { * * Override this! * - * @param WebRequest $request + * @param string $answer * @param array $info * @return bool */ - function keyMatch( $request, $info ) { - return $request->getVal( 'wpCaptchaWord' ) == $info['answer']; + function keyMatch( $answer, $info ) { + return $answer == $info['answer']; } // ---------------------------------- @@ -508,7 +508,7 @@ class SimpleCaptcha { $info = $this->retrieveCaptcha(); if( $info ) { global $wgRequest; - if( $this->keyMatch( $wgRequest, $info ) ) { + if( $this->keyMatch( $wgRequest->getVal('wpCaptchaWord'), $info ) ) { $this->log( "passed" ); $this->clearCaptcha( $info ); return true; diff --git a/FancyCaptcha.class.php b/FancyCaptcha.class.php index 93b49ff..fa96820 100644 --- a/FancyCaptcha.class.php +++ b/FancyCaptcha.class.php @@ -5,14 +5,13 @@ class FancyCaptcha extends SimpleCaptcha { * Check if the submitted form matches the captcha session data provided * by the plugin when the form was generated. * - * @param WebRequest $request + * @param string $answer * @param array $info * @return bool */ - function keyMatch( $request, $info ) { + function keyMatch( $answer, $info ) { global $wgCaptchaSecret; - $answer = $request->getVal( 'wpCaptchaWord' ); $digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt']; $answerHash = substr( md5( $digest ), 0, 16 ); diff --git a/MathCaptcha.class.php b/MathCaptcha.class.php index 01d6391..adf1663 100644 --- a/MathCaptcha.class.php +++ b/MathCaptcha.class.php @@ -3,8 +3,8 @@ class MathCaptcha extends SimpleCaptcha { /** Validate a captcha response */ - function keyMatch( $req, $info ) { - return (int)$req->getVal( 'wpCaptchaAnswer' ) == (int)$info['answer']; + function keyMatch( $answer, $info ) { + return (int)$answer == (int)$info['answer']; } /** Produce a nice little form */