wphooks.info - sanitize_file_name_chars

sanitize_file_name_chars

(trunk - 5.1-alpha-44286)

The hook occurs in the following file:

wp-includes/formatting.php:
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
	$filename_raw  = $filename;
	$special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) );
	/**
	 * Filters the list of characters to remove from a filename.
	 *
	 * @since 2.8.0
	 *
	 * @param array  $special_chars Characters to remove.
	 * @param string $filename_raw  Filename as it was passed into sanitize_file_name().
	 */
	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
	$filename      = preg_replace( "#\x{00a0}#siu", ' ', $filename );
	$filename      = str_replace( $special_chars, '', $filename );
	$filename      = str_replace( array( '%20', '+' ), '-', $filename );
	$filename      = preg_replace( '/[\r\n\t -]+/', '-', $filename );
	$filename      = trim( $filename, '.-_' );

	if ( false === strpos( $filename, '.' ) ) {
		$mime_types = wp_get_mime_types();
		$filetype   = wp_check_filetype( 'test.' . $filename, $mime_types );