[wp-trac] [WordPress Trac] #18412: "%20" in an uploaded image file name breaks thumbnails
WordPress Trac
noreply at wordpress.org
Tue Jun 17 20:40:30 UTC 2014
#18412: "%20" in an uploaded image file name breaks thumbnails
-----------------------------------------------------+------------------
Reporter: ripperdoc | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.0
Component: Media | Version: 2.1
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests dev-feedback | Focuses:
-----------------------------------------------------+------------------
Changes (by simonwheatley):
* keywords: has-patch needs-unit-tests => has-patch needs-unit-tests dev-
feedback
Comment:
Replying to [comment:17 wonderboymusic]:
> This looks fine, but the bug and fix need to be demonstrated via a unit
test.
I cannot see how to demonstrate this bug in `wp_handle_upload` via a unit
test (not to say it's not possible). I've created a not-uploaded fake
file, and overridden as many tests as possible. Unfortunately the tests
fails (not in a good way) on the `move_uploaded_file` call, which (I
assume) detects that it's not a properly uploaded file and then the
`wp_handle_upload` function fails.
Any ideas for how we can get around this?
My test so far:
{{{
/*
* @ticket 18412
*/
function test_unique_filename_encoded_space_is_sanitized() {
$tmp_file_name = wp_tempnam();
file_put_contents( $tmp_file_name, 'xxxxxxxxxxxxxxxx' );
$overrides = array(
'test_form' => false,
'test_size' => false,
'test_upload' => false,
);
$fake_file = array(
'name' => 'hello%20world.png',
'type' => 'image/png',
'size' => '16',
'tmp_name' => $tmp_file_name,
'error' => UPLOAD_ERR_OK,
);
$results = wp_handle_upload( $fake_file, $overrides );
// Some assertions to go here, haven't got that far
unlink( $tmp_file_name );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/18412#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list