From: Bryan Tong Minh Date: Sat, 18 Jun 2011 14:56:14 +0000 (+0000) Subject: (bug 29408) Key 'something.' is not in a proper format X-Git-Tag: 1.31.0-rc.0~29444 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=9bbe0bc56625bad3740f485fb8275fea56fcf5af;p=lhc%2Fweb%2Fwiklou.git (bug 29408) Key 'something.' is not in a proper format Fixed this by relaxing the stash key regex. For some files MediaWiki is simply not able to guess an extension. If the wiki has been configured to allow them, we should just let them pass in the stash as well. --- diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 2412643bc4..f926584d96 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -14,7 +14,7 @@ class UploadStash { // Format of the key for files -- has to be suitable as a filename itself (e.g. ab12cd34ef.jpg) - const KEY_FORMAT_REGEX = '/^[\w-]+\.\w+$/'; + const KEY_FORMAT_REGEX = '/^[\w-]+\.\w*$/'; /** * repository that this uses to store temp files diff --git a/tests/phpunit/includes/upload/UploadStashTest.php b/tests/phpunit/includes/upload/UploadStashTest.php new file mode 100644 index 0000000000..c34714a275 --- /dev/null +++ b/tests/phpunit/includes/upload/UploadStashTest.php @@ -0,0 +1,35 @@ +bug29408File = dirname( __FILE__ ) . '/bug29408'; + file_put_contents( $this->bug29408File, "\x00" ); + } + + public function testBug29408() { + $repo = RepoGroup::singleton()->getLocalRepo(); + $stash = new UploadStash( $repo ); + + // Throws exception caught by PHPUnit on failure + $file = $stash->stashFile( $this->bug29408File ); + // We'll never reach this point if we hit bug 29408 + $this->assertTrue( true, 'Unrecognized file without extension' ); + + $file->remove(); + } + + public function tearDown() { + parent::tearDown(); + + unlink( $this->bug29408File ); + + } +} \ No newline at end of file