mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
Upload: fix wp_unique_filename() to prevent name collisions with existing or future image sub-size file names, and add unit tests.
Props Viper007Bond, pbiron, azaozz. Fixes #42437. git-svn-id: https://develop.svn.wordpress.org/trunk@46822 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -195,6 +195,19 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 42437
|
||||
*/
|
||||
function test_unique_filename_with_dimension_like_filename() {
|
||||
$testdir = DIR_TESTDATA . '/images/';
|
||||
|
||||
// Test collision with "dimension-like" original filename.
|
||||
$this->assertEquals( 'one-blue-pixel-100x100-1.png', wp_unique_filename( $testdir, 'one-blue-pixel-100x100.png' ) );
|
||||
// Test collision with existing sub-size filename.
|
||||
// Existing files: one-blue-pixel-100x100.png, one-blue-pixel-1-100x100.png.
|
||||
$this->assertEquals( 'one-blue-pixel-2.png', wp_unique_filename( $testdir, 'one-blue-pixel.png' ) );
|
||||
}
|
||||
|
||||
function test_is_serialized() {
|
||||
$cases = array(
|
||||
serialize( null ),
|
||||
|
||||
Reference in New Issue
Block a user