Changeset 44443
- Timestamp:
- 01/07/2019 10:22:03 PM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 3 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0
- Property svn:mergeinfo changed
/trunk merged: 44438-44439,44441-44442
- Property svn:mergeinfo changed
-
branches/5.0/src/wp-includes/functions.php
r44407 r44443 2374 2374 * and some media files are commonly named with the wrong extension (.mov instead of .mp4) 2375 2375 */ 2376 2377 2376 if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) { 2377 $type = $ext = false; 2378 } 2379 } elseif ( 'text/plain' === $real_mime ) { 2380 // A few common file types are occasionally detected as text/plain; allow those. 2381 if ( ! in_array( 2382 $type, 2383 array( 2384 'text/plain', 2385 'text/csv', 2386 'text/richtext', 2387 'text/tsv', 2388 'text/vtt', 2389 ) 2390 ) 2391 ) { 2392 $type = $ext = false; 2393 } 2394 } elseif ( 'text/rtf' === $real_mime ) { 2395 // Special casing for RTF files. 2396 if ( ! in_array( 2397 $type, 2398 array( 2399 'text/rtf', 2400 'text/plain', 2401 'application/rtf', 2402 ) 2403 ) 2404 ) { 2378 2405 $type = $ext = false; 2379 2406 } -
branches/5.0/tests/phpunit/tests/functions.php
r44407 r44443 1073 1073 1074 1074 /** 1075 * Data pro fider for test_wp_get_image_mime();1075 * Data provider for test_wp_get_image_mime(); 1076 1076 */ 1077 1077 public function _wp_get_image_mime() { … … 1179 1179 ), 1180 1180 ), 1181 // Non-image file not allowed even if it's named like one. 1182 array( 1183 DIR_TESTDATA . '/export/crazy-cdata.xml', 1184 'crazy-cdata.jpg', 1185 array( 1186 'ext' => false, 1187 'type' => false, 1188 'proper_filename' => false, 1189 ), 1190 ), 1191 // Non-image file not allowed if it's named like something else. 1192 array( 1193 DIR_TESTDATA . '/export/crazy-cdata.xml', 1194 'crazy-cdata.doc', 1195 array( 1196 'ext' => false, 1197 'type' => false, 1198 'proper_filename' => false, 1199 ), 1200 ), 1181 1201 ); 1182 1202 1183 1203 // Test a few additional file types on single sites. 1184 1204 if ( ! is_multisite() ) { 1185 $data = array_merge( $data, array(1186 // Standard non-image file.1205 $data = array_merge( 1206 $data, 1187 1207 array( 1188 DIR_TESTDATA . '/formatting/big5.txt', 1189 'big5.txt', 1208 // Standard non-image file. 1190 1209 array( 1191 'ext' => 'txt', 1192 'type' => 'text/plain', 1193 'proper_filename' => false, 1210 DIR_TESTDATA . '/formatting/big5.txt', 1211 'big5.txt', 1212 array( 1213 'ext' => 'txt', 1214 'type' => 'text/plain', 1215 'proper_filename' => false, 1216 ), 1194 1217 ), 1195 ), 1196 // Non-image file with wrong sub-type. 1197 array( 1198 DIR_TESTDATA . '/uploads/pages-to-word.docx', 1199 'pages-to-word.docx', 1218 // Non-image file with wrong sub-type. 1200 1219 array( 1201 'ext' => 'docx', 1202 'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1203 'proper_filename' => false, 1220 DIR_TESTDATA . '/uploads/pages-to-word.docx', 1221 'pages-to-word.docx', 1222 array( 1223 'ext' => 'docx', 1224 'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1225 'proper_filename' => false, 1226 ), 1204 1227 ), 1205 ), 1206 // FLAC file. 1207 array( 1208 DIR_TESTDATA . '/uploads/small-audio.flac', 1209 'small-audio.flac', 1228 // FLAC file. 1210 1229 array( 1211 'ext' => 'flac', 1212 'type' => 'audio/flac', 1213 'proper_filename' => false, 1230 DIR_TESTDATA . '/uploads/small-audio.flac', 1231 'small-audio.flac', 1232 array( 1233 'ext' => 'flac', 1234 'type' => 'audio/flac', 1235 'proper_filename' => false, 1236 ), 1214 1237 ), 1215 ), 1216 ) ); 1238 // Assorted text/* sample files 1239 array( 1240 DIR_TESTDATA . '/uploads/test.vtt', 1241 'test.vtt', 1242 array( 1243 'ext' => 'vtt', 1244 'type' => 'text/vtt', 1245 'proper_filename' => false, 1246 ), 1247 ), 1248 array( 1249 DIR_TESTDATA . '/uploads/test.csv', 1250 'test.csv', 1251 array( 1252 'ext' => 'csv', 1253 'type' => 'text/csv', 1254 'proper_filename' => false, 1255 ), 1256 ), 1257 // RTF files. 1258 array( 1259 DIR_TESTDATA . '/uploads/test.rtf', 1260 'test.rtf', 1261 array( 1262 'ext' => 'rtf', 1263 'type' => 'application/rtf', 1264 'proper_filename' => false, 1265 ), 1266 ), 1267 ) 1268 ); 1217 1269 } 1218 1270
Note: See TracChangeset
for help on using the changeset viewer.