Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -564,6 +564,24 @@ |
565 | 565 | $this->mFinalExtension = trim( $ext[count( $ext ) - 1] ); |
566 | 566 | } else { |
567 | 567 | $this->mFinalExtension = ''; |
| 568 | + |
| 569 | + # No extension, try guessing one |
| 570 | + $magic = MimeMagic::singleton(); |
| 571 | + $mime = $magic->guessMimeType( $this->mTempPath ); |
| 572 | + if ( $mime !== 'unknown/unknown' ) { |
| 573 | + # Get a space separated list of extensions |
| 574 | + $extList = $magic->getExtensionsForType( $mime ); |
| 575 | + if ( $extList ) { |
| 576 | + # Set the extension to the canonical extension |
| 577 | + $this->mFinalExtension = strtok( $extList, ' ' ); |
| 578 | + |
| 579 | + # Fix up the other variables |
| 580 | + $this->mFilteredName .= ".{$this->mFinalExtension}"; |
| 581 | + $nt = Title::makeTitleSafe( NS_FILE, $this->mFilteredName ); |
| 582 | + $ext = array( $this->mFinalExtension ); |
| 583 | + } |
| 584 | + } |
| 585 | + |
568 | 586 | } |
569 | 587 | |
570 | 588 | /* Don't allow users to override the blacklist (check file extension) */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -55,6 +55,8 @@ |
56 | 56 | * Upload warnings now show a thumbnail of the uploaded file |
57 | 57 | * Introduced the edittools-upload message, which will be inserted under the |
58 | 58 | upload form instead of edittools if available |
| 59 | +* (bug 26285) Extensions will be automatically generated on upload if the user |
| 60 | + specified a filename without extension. |
59 | 61 | |
60 | 62 | === Bug fixes in 1.18 === |
61 | 63 | * (bug 23119) WikiError class and subclasses are now marked as deprecated |