Ticket #7484: 7484.01.patch
File 7484.01.patch, 1.7 KB (added by , 8 years ago) |
---|
-
src/bp-core/classes/class-bp-attachment.php
268 268 add_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args ); 269 269 } 270 270 271 // Helper for utf-8 filenames. 272 add_filter( 'sanitize_file_name', array( $this, 'sanitize_utf8_filename' ) ); 273 271 274 // Upload the attachment. 272 275 $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time ); 273 276 277 remove_filter( 'sanitize_file_name', array( $this, 'sanitize_utf8_filename' ) ); 278 274 279 // Restore WordPress Uploads data. 275 280 if ( ! empty( $upload_dir_filter ) ) { 276 281 remove_filter( 'upload_dir', $upload_dir_filter, 10 ); … … 284 289 } 285 290 286 291 /** 292 * Helper to convert utf-8 characters in filenames to their ASCII equivalent. 293 * 294 * @since 2.9.0 295 * 296 * @param string $retval Filename. 297 * @return string 298 */ 299 public function sanitize_utf8_filename( $retval ) { 300 // PHP 5.4+ or with PECL intl 2.0+ 301 if ( function_exists( 'transliterator_transliterate' ) && seems_utf8( $retval ) ) { 302 $retval = transliterator_transliterate( 'Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove', $retval ); 303 304 // Older. 305 } else { 306 // Use WP's built-in function to convert accents to their ASCII equivalent. 307 $retval = remove_accents( $retval ); 308 309 // Still here? use iconv(). 310 if ( function_exists( 'iconv' ) && seems_utf8( $retval ) ) { 311 $retval = iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $retval ); 312 } 313 } 314 315 return $retval; 316 } 317 318 /** 287 319 * Validate the allowed mime types using WordPress allowed mime types. 288 320 * 289 321 * In case of a multisite, the mime types are already restricted by