Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3247,6 +3247,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
'text/richtext',
'text/tsv',
'text/vtt',
'application/json',
),
true
)
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/data/uploads/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"just a string"
26 changes: 26 additions & 0 deletions tests/phpunit/tests/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,32 @@ public function data_wp_check_filetype_and_ext() {
return $data;
}

/**
* @ticket 54193
* @group ms-excluded
* @requires extension fileinfo
*/
public function test_wp_check_filetype_and_ext_with_filtered_json() {
$file = DIR_TESTDATA . '/uploads/test.json';
$filename = 'test.json';

$expected = array(
'ext' => 'json',
'type' => 'application/json',
'proper_filename' => false,
);

add_filter(
'upload_mimes',
static function ( $mimes ) {
$mimes['json'] = 'application/json';
return $mimes;
}
);

$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
}

/**
* @ticket 39550
* @group ms-excluded
Expand Down
Loading