Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -631,6 +631,14 @@ |
632 | 632 | } |
633 | 633 | $this->mFilteredName = $nt->getDBkey(); |
634 | 634 | |
| 635 | + # oi_archive_name is max 255 bytes, which include a timestamp and an |
| 636 | + # exclamation mark, so restrict file name to 240 bytes. Return |
| 637 | + # ILLEGAL_FILENAME, just like would have happened for >255 bytes |
| 638 | + if ( strlen( $this->mFilteredName ) > 240 ) { |
| 639 | + $this->mTitleError = self::ILLEGAL_FILENAME; |
| 640 | + return $this->mTitle = null; |
| 641 | + } |
| 642 | + |
635 | 643 | /** |
636 | 644 | * We'll want to blacklist against *any* 'extension', and use |
637 | 645 | * only the final one for the whitelist. |
Index: trunk/phase3/tests/phpunit/includes/upload/UploadTest.php |
— | — | @@ -60,6 +60,16 @@ |
61 | 61 | $this->assertUploadTitleAndCode( '.jpg', |
62 | 62 | null, UploadBase::MIN_LENGTH_PARTNAME, |
63 | 63 | 'upload title without basename' ); |
| 64 | + |
| 65 | + /* A title that is longer than 255 bytes */ |
| 66 | + $this->assertUploadTitleAndCode( str_repeat( 'a', 255 ) . '.jpg', |
| 67 | + null, UploadBase::ILLEGAL_FILENAME, |
| 68 | + 'upload title longer than 255 bytes' ); |
| 69 | + |
| 70 | + /* A title that is longer than 240 bytes */ |
| 71 | + $this->assertUploadTitleAndCode( str_repeat( 'a', 240 ) . '.jpg', |
| 72 | + null, UploadBase::ILLEGAL_FILENAME, |
| 73 | + 'upload title longer than 240 bytes' ); |
64 | 74 | |
65 | 75 | } |
66 | 76 | /** |
— | — | @@ -134,6 +144,7 @@ |
135 | 145 | public function testTitleValidation( $name ) { |
136 | 146 | $this->mTitle = false; |
137 | 147 | $this->mDesiredDestName = $name; |
| 148 | + $this->mTitleError = UploadBase::OK; |
138 | 149 | $this->getTitle(); |
139 | 150 | return $this->mTitleError; |
140 | 151 | } |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -107,6 +107,8 @@ |
108 | 108 | * Per page edit-notices now work in namespaces without subpages enabled. |
109 | 109 | * (bug 30245) Use the correct way to construct a log page title |
110 | 110 | * (bug 31081) $wgEnotifUseJobQ causes many unnecessary jobs to be queued |
| 111 | +* (bug 30202) File names are now restricted on upload to 240 bytes, because of |
| 112 | + restrictions on some of the database fields. |
111 | 113 | |
112 | 114 | === API changes in 1.19 === |
113 | 115 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |