r99490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99489‎ | r99490 | r99491 >
Date:16:17, 11 October 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
submission field should not be required
Modified paths:
  • /trunk/extensions/Contest/specials/SpecialContestSubmission.php (modified) (history)
  • /trunk/extensions/Contest/test/ContestValidationTests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/test/ContestValidationTests.php
@@ -24,6 +24,9 @@
2525 'https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53ba' => false,
2626 'https://github.com/JeroenDeDauw/smwc*/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => false,
2727 'in ur unit test, being quite silly' => false,
 28+ ' https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b ' => true,
 29+ '' => true,
 30+ ' ' => true,
2831 );
2932
3033 foreach ( $tests as $test => $isValdid ) {
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php
@@ -152,7 +152,7 @@
153153 'wmf' => $data['contestant-wmf'],
154154 'cv' => $data['contestant-cv'],
155155
156 - 'submission' => $data['contestant-submission'],
 156+ 'submission' => trim( $data['contestant-submission'] ),
157157 ) );
158158
159159 return $contestant->writeToDB();
@@ -302,6 +302,12 @@
303303 * @return true|string
304304 */
305305 public static function validateSubmissionField( $value, $alldata = null ) {
 306+ $value = trim( $value );
 307+
 308+ if ( $value == '' ) {
 309+ return true;
 310+ }
 311+
306312 $allowedPatterns = array(
307313 // GitHub URLs such as https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b
308314 '@^https://github\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_-]+/tree/[a-zA-Z0-9]{40}$@i'

Status & tagging log