Ticket #46800: bad_id3_patch_2.diff
File bad_id3_patch_2.diff, 2.0 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/media.php
3260 3260 } 3261 3261 3262 3262 /** 3263 * Sanitizes metadata extracted from media files. 3264 * 3265 * Currently only binary strings are sanitized with focus on preventing propagation of 3266 * bad character encodings from causing database calls and API endpoints to fail. 3267 * 3268 * @param array $metadata An existing array with data 3269 * 3270 * @return array Returns array of sanitized metadata. 3271 */ 3272 function wp_sanitize_media_metadata( $metadata ) { 3273 if ( ! is_array( $metadata ) ) { 3274 return $metadata; 3275 } 3276 foreach ( $metadata as $name => $value ) { 3277 if ( ! is_string( $value ) ) { 3278 continue; 3279 } 3280 if ( is_array( $value ) ) { 3281 $value = wp_sanitize_media_metadata( $value ); 3282 } elseif ( is_string( $value ) && preg_match('~[^\x20-\x7E\t\r\n]~', $value ) > 0 ) { 3283 $encoding = mb_detect_encoding( $value, 'ISO-8859-1, UCS-2' ); 3284 $value = $encoding ? mb_convert_encoding( $value, 'UTF-8', $encoding ) : utf8_encode( $value ); 3285 } 3286 $metadata[$name] = $value; 3287 } 3288 return $metadata; 3289 } 3290 3291 /** 3263 3292 * Retrieve metadata from a video file's ID3 tags 3264 3293 * 3265 3294 * @since 3.6.0 … … 3341 3370 3342 3371 $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; 3343 3372 3373 $metadata = wp_sanitize_media_metadata( $metadata ); 3374 3344 3375 /** 3345 3376 * Filters the array of metadata retrieved from a video. 3346 3377 * … … 3412 3443 3413 3444 wp_add_id3_tag_data( $metadata, $data ); 3414 3445 3446 $metadata = wp_sanitize_media_metadata( $metadata ); 3447 3415 3448 return $metadata; 3416 3449 } 3417 3450 -
src/wp-includes/post.php
5538 5538 } 5539 5539 5540 5540 $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true ); 5541 5541 $data = wp_sanitize_media_metadata( $data ); 5542 5542 5543 if ( $unfiltered ) { 5543 5544 return $data; 5544 5545 }