diff --git src/wp-admin/includes/media.php src/wp-admin/includes/media.php
index 35aa791..1405e85 100644
|
|
|
function media_handle_upload($file_id, $post_id, $post_data = array(), $override |
| 278 | 278 | $time = $post->post_date; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | | $name = $_FILES[$file_id]['name']; |
| 282 | 281 | $file = wp_handle_upload($_FILES[$file_id], $overrides, $time); |
| 283 | 282 | |
| 284 | 283 | if ( isset($file['error']) ) |
| 285 | 284 | return new WP_Error( 'upload_error', $file['error'] ); |
| 286 | 285 | |
| 287 | | $basename = pathinfo( $name, PATHINFO_BASENAME ); |
| | 286 | $name = pathinfo( $_FILES[$file_id]['name'], PATHINFO_FILENAME ); |
| 288 | 287 | |
| 289 | 288 | $url = $file['url']; |
| 290 | 289 | $type = $file['type']; |
| 291 | 290 | $file = $file['file']; |
| 292 | | $title = sanitize_title( $basename ); |
| | 291 | $title = sanitize_text_field( $name ); |
| 293 | 292 | $content = ''; |
| 294 | 293 | $excerpt = ''; |
| 295 | 294 | |
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
index debf5ac..5b4b5de 100644
|
|
|
VIDEO; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | /** |
| | 776 | * @ticket 37989 |
| | 777 | */ |
| | 778 | public function test_media_handle_upload_expected_titles() { |
| | 779 | $test_file = DIR_TESTDATA . '/images/test-image.jpg'; |
| | 780 | |
| | 781 | // Make a copy of this file as it gets moved during the file upload |
| | 782 | $tmp_name = wp_tempnam( $test_file ); |
| | 783 | |
| | 784 | copy( $test_file, $tmp_name ); |
| | 785 | |
| | 786 | $_FILES['upload'] = array( |
| | 787 | 'tmp_name' => $tmp_name, |
| | 788 | 'name' => 'This is a test.jpg', |
| | 789 | 'type' => 'image/jpeg', |
| | 790 | 'error' => 0, |
| | 791 | 'size' => filesize( $test_file ), |
| | 792 | ); |
| | 793 | |
| | 794 | $post_id = media_handle_upload( 'upload', 0, array(), array( 'action' => 'test_upload_titles', 'test_form' => false ) ); |
| | 795 | |
| | 796 | unset( $_FILES['upload'] ); |
| | 797 | |
| | 798 | $post = get_post( $post_id ); |
| | 799 | |
| | 800 | // Clean up. |
| | 801 | wp_delete_attachment( $post_id ); |
| | 802 | |
| | 803 | $this->assertEquals( 'This is a test', $post->post_title ); |
| | 804 | } |
| | 805 | |
| | 806 | /** |
| 776 | 807 | * @ticket 33016 |
| 777 | 808 | */ |
| 778 | 809 | function test_multiline_cdata() { |