Index: trunk/extensions/Contest/test/ContestValidationTests.php |
— | — | @@ -24,6 +24,9 @@ |
25 | 25 | 'https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53ba' => false, |
26 | 26 | 'https://github.com/JeroenDeDauw/smwc*/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => false, |
27 | 27 | 'in ur unit test, being quite silly' => false, |
| 28 | + ' https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b ' => true, |
| 29 | + '' => true, |
| 30 | + ' ' => true, |
28 | 31 | ); |
29 | 32 | |
30 | 33 | foreach ( $tests as $test => $isValdid ) { |
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | 'wmf' => $data['contestant-wmf'], |
154 | 154 | 'cv' => $data['contestant-cv'], |
155 | 155 | |
156 | | - 'submission' => $data['contestant-submission'], |
| 156 | + 'submission' => trim( $data['contestant-submission'] ), |
157 | 157 | ) ); |
158 | 158 | |
159 | 159 | return $contestant->writeToDB(); |
— | — | @@ -302,6 +302,12 @@ |
303 | 303 | * @return true|string |
304 | 304 | */ |
305 | 305 | public static function validateSubmissionField( $value, $alldata = null ) { |
| 306 | + $value = trim( $value ); |
| 307 | + |
| 308 | + if ( $value == '' ) { |
| 309 | + return true; |
| 310 | + } |
| 311 | + |
306 | 312 | $allowedPatterns = array( |
307 | 313 | // GitHub URLs such as https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b |
308 | 314 | '@^https://github\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_-]+/tree/[a-zA-Z0-9]{40}$@i' |