Skip to:
Content

BuddyPress.org

Ticket #7484: 7484.iconv.patch

File 7484.iconv.patch, 1.4 KB (added by r-a-y, 8 years ago)
  • src/bp-core/classes/class-bp-attachment.php

     
    268268                        add_filter( 'upload_dir', $upload_dir_filter, 10, $this->upload_dir_filter_args );
    269269                }
    270270
     271                // Helper for utf-8 filenames.
     272                if ( function_exists( 'iconv' ) ) {
     273                        add_filter( 'sanitize_file_name', array( $this, 'iconv' ) );
     274                }
     275
    271276                // Upload the attachment.
    272277                $this->attachment = wp_handle_upload( $file[ $this->file_input ], $overrides, $time );
    273278
     
    276281                        remove_filter( 'upload_dir', $upload_dir_filter, 10 );
    277282                }
    278283
     284                if ( function_exists( 'iconv' ) ) {
     285                        remove_filter( 'sanitize_file_name', array( $this, 'iconv' ) );
     286                }
     287
    279288                // Remove the pre WordPress 4.0 static filter.
    280289                remove_filter( 'wp_handle_upload_prefilter', array( $this, 'validate_upload' ), 10 );
    281290
     
    284293        }
    285294
    286295        /**
     296         * Helper to convert utf-8 characters in filenames to their ASCII equivalent.
     297         *
     298         * @since 2.9.0
     299         *
     300         * @param  string $retval Filename.
     301         * @return string
     302         */
     303        public function iconv( $retval ) {
     304                return iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $retval );
     305        }
     306
     307        /**
    287308         * Validate the allowed mime types using WordPress allowed mime types.
    288309         *
    289310         * In case of a multisite, the mime types are already restricted by