r30132 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30131‎ | r30132 | r30133 >
Date:21:42, 24 January 2008
Author:catrope
Status:old
Tags:
Comment:
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
Modified paths:
  • /trunk/extensions/ConfirmEdit/ConfirmEdit_body.php (modified) (history)
  • /trunk/extensions/ConfirmEdit/FancyCaptcha.class.php (modified) (history)
  • /trunk/extensions/ConfirmEdit/MathCaptcha.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmEdit/ConfirmEdit_body.php
@@ -206,12 +206,12 @@
207207 *
208208 * Override this!
209209 *
210 - * @param WebRequest $request
 210+ * @param string $answer
211211 * @param array $info
212212 * @return bool
213213 */
214 - function keyMatch( $request, $info ) {
215 - return $request->getVal( 'wpCaptchaWord' ) == $info['answer'];
 214+ function keyMatch( $answer, $info ) {
 215+ return $answer == $info['answer'];
216216 }
217217
218218 // ----------------------------------
@@ -508,7 +508,7 @@
509509 $info = $this->retrieveCaptcha();
510510 if( $info ) {
511511 global $wgRequest;
512 - if( $this->keyMatch( $wgRequest, $info ) ) {
 512+ if( $this->keyMatch( $wgRequest->getVal('wpCaptchaWord'), $info ) ) {
513513 $this->log( "passed" );
514514 $this->clearCaptcha( $info );
515515 return true;
Index: trunk/extensions/ConfirmEdit/MathCaptcha.class.php
@@ -3,8 +3,8 @@
44 class MathCaptcha extends SimpleCaptcha {
55
66 /** Validate a captcha response */
7 - function keyMatch( $req, $info ) {
8 - return (int)$req->getVal( 'wpCaptchaAnswer' ) == (int)$info['answer'];
 7+ function keyMatch( $answer, $info ) {
 8+ return (int)$answer == (int)$info['answer'];
99 }
1010
1111 /** Produce a nice little form */
Index: trunk/extensions/ConfirmEdit/FancyCaptcha.class.php
@@ -5,14 +5,13 @@
66 * Check if the submitted form matches the captcha session data provided
77 * by the plugin when the form was generated.
88 *
9 - * @param WebRequest $request
 9+ * @param string $answer
1010 * @param array $info
1111 * @return bool
1212 */
13 - function keyMatch( $request, $info ) {
 13+ function keyMatch( $answer, $info ) {
1414 global $wgCaptchaSecret;
1515
16 - $answer = $request->getVal( 'wpCaptchaWord' );
1716 $digest = $wgCaptchaSecret . $info['salt'] . $answer . $wgCaptchaSecret . $info['salt'];
1817 $answerHash = substr( md5( $digest ), 0, 16 );
1918

Status & tagging log