Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -1331,7 +1331,7 @@ |
1332 | 1332 | |
1333 | 1333 | wfDebug ( "\n\nmime: <$mime> extension: <$extension>\n\n"); |
1334 | 1334 | #check mime type against file extension |
1335 | | - if( !$this->verifyExtension( $mime, $extension ) ) { |
| 1335 | + if( !self::verifyExtension( $mime, $extension ) ) { |
1336 | 1336 | return new WikiErrorMsg( 'uploadcorrupt' ); |
1337 | 1337 | } |
1338 | 1338 | |
— | — | @@ -1367,7 +1367,7 @@ |
1368 | 1368 | * @param string $extension The filename extension that the file is to be served with |
1369 | 1369 | * @return bool |
1370 | 1370 | */ |
1371 | | - function verifyExtension( $mime, $extension ) { |
| 1371 | + static function verifyExtension( $mime, $extension ) { |
1372 | 1372 | $magic = MimeMagic::singleton(); |
1373 | 1373 | |
1374 | 1374 | if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) |
Index: trunk/extensions/ConfirmAccount/RequestAccount_body.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | $wgOut->blockedPage(); |
25 | 25 | return; |
26 | 26 | } |
27 | | - if ( wfReadOnly() ) { |
| 27 | + if( wfReadOnly() ) { |
28 | 28 | $wgOut->readOnlyPage(); |
29 | 29 | return; |
30 | 30 | } |
— | — | @@ -71,9 +71,8 @@ |
72 | 72 | |
73 | 73 | $this->skin = $wgUser->getSkin(); |
74 | 74 | |
75 | | - if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
76 | | - if( !$this->mPrevAttachment ) |
77 | | - $this->mPrevAttachment = $this->mSrcName; |
| 75 | + if( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) { |
| 76 | + $this->mPrevAttachment = $this->mPrevAttachment ? $this->mPrevAttachment : $this->mSrcName; |
78 | 77 | $this->doSubmit(); |
79 | 78 | } else if( $action == 'confirmemail' ) { |
80 | 79 | $this->confirmEmailToken( $emailCode ); |
— | — | @@ -245,6 +244,7 @@ |
246 | 245 | $this->showForm( $abortError ); |
247 | 246 | return; |
248 | 247 | } |
| 248 | + # Set it back! |
249 | 249 | if( !$wgConfirmAccountCaptchas && isset($wgCaptchaTriggers) ) { |
250 | 250 | $wgCaptchaTriggers['createaccount'] = $old; |
251 | 251 | } |
— | — | @@ -301,7 +301,6 @@ |
302 | 302 | $this->showForm( wfMsgHtml('requestaccount-emaildup') ); |
303 | 303 | return; |
304 | 304 | } |
305 | | - |
306 | 305 | $u->setRealName( $this->mRealName ); |
307 | 306 | # Per security reasons, file dir cannot be pulled from client, |
308 | 307 | # so ask them to resubmit it then... |
— | — | @@ -413,7 +412,6 @@ |
414 | 413 | # BC: check if isPingLimitable() exists |
415 | 414 | if( $wgAccountRequestThrottle && ( !method_exists($wgUser,'isPingLimitable') || $wgUser->isPingLimitable() ) ) { |
416 | 415 | global $wgMemc; |
417 | | - |
418 | 416 | $key = wfMemcKey( 'acctrequest', 'ip', wfGetIP() ); |
419 | 417 | $value = $wgMemc->incr( $key ); |
420 | 418 | if( !$value ) { |
— | — | @@ -426,15 +424,13 @@ |
427 | 425 | |
428 | 426 | function showSuccess() { |
429 | 427 | global $wgOut; |
430 | | - |
431 | 428 | $wgOut->setPagetitle( wfMsg( "requestaccount" ) ); |
432 | 429 | $wgOut->addWikiText( wfMsg( "requestaccount-sent" ) ); |
433 | | - |
434 | 430 | $wgOut->returnToMain(); |
435 | 431 | } |
436 | 432 | |
437 | 433 | /** |
438 | | - * Flatten an areas of interest array |
| 434 | + * Flatten areas of interest array |
439 | 435 | * @access private |
440 | 436 | */ |
441 | 437 | static function flattenAreas( $areas ) { |
— | — | @@ -445,6 +441,10 @@ |
446 | 442 | return $flatAreas; |
447 | 443 | } |
448 | 444 | |
| 445 | + /** |
| 446 | + * Expand areas of interest to array |
| 447 | + * @access private |
| 448 | + */ |
449 | 449 | static function expandAreas( $areas ) { |
450 | 450 | $list = explode("\n",$areas); |
451 | 451 | foreach( $list as $n => $item ) { |
— | — | @@ -483,7 +483,7 @@ |
484 | 484 | |
485 | 485 | wfDebug ( "\n\nmime: <$mime> extension: <$extension>\n\n"); |
486 | 486 | #check mime type against file extension |
487 | | - if( !$this->verifyExtension( $mime, $extension ) ) { |
| 487 | + if( !UploadForm::verifyExtension( $mime, $extension ) ) { |
488 | 488 | return new WikiErrorMsg( 'uploadcorrupt' ); |
489 | 489 | } |
490 | 490 | |
— | — | @@ -500,44 +500,6 @@ |
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
504 | | - * Checks if the mime type of the uploaded file matches the file extension. |
505 | | - * |
506 | | - * @param string $mime the mime type of the uploaded file |
507 | | - * @param string $extension The filename extension that the file is to be served with |
508 | | - * @return bool |
509 | | - */ |
510 | | - function verifyExtension( $mime, $extension ) { |
511 | | - $magic =& MimeMagic::singleton(); |
512 | | - |
513 | | - if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' ) |
514 | | - if ( ! $magic->isRecognizableExtension( $extension ) ) { |
515 | | - wfDebug( __METHOD__.": passing file with unknown detected mime type; " . |
516 | | - "unrecognized extension '$extension', can't verify\n" ); |
517 | | - return true; |
518 | | - } else { |
519 | | - wfDebug( __METHOD__.": rejecting file with unknown detected mime type; ". |
520 | | - "recognized extension '$extension', so probably invalid file\n" ); |
521 | | - return false; |
522 | | - } |
523 | | - |
524 | | - $match = $magic->isMatchingExtension($extension,$mime); |
525 | | - |
526 | | - if ($match===NULL) { |
527 | | - wfDebug( __METHOD__.": no file extension known for mime type $mime, passing file\n" ); |
528 | | - return true; |
529 | | - } elseif ($match===true) { |
530 | | - wfDebug( __METHOD__.": mime type $mime matches extension $extension, passing file\n" ); |
531 | | - |
532 | | - #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it! |
533 | | - return true; |
534 | | - |
535 | | - } else { |
536 | | - wfDebug( __METHOD__.": mime type $mime mismatches file extension $extension, rejecting file\n" ); |
537 | | - return false; |
538 | | - } |
539 | | - } |
540 | | - |
541 | | - /** |
542 | 504 | * Perform case-insensitive match against a list of file extensions. |
543 | 505 | * Returns true if the extension is in the list. |
544 | 506 | * |