Ticket #21013: 21013.2.patch
File 21013.2.patch, 4.3 KB (added by , 12 years ago) |
---|
-
wp-includes/compat.php
14 14 } 15 15 16 16 if ( !function_exists('mb_substr') ): 17 function mb_substr( $str, $start, $length =null, $encoding=null ) {17 function mb_substr( $str, $start, $length = null, $encoding = null ) { 18 18 return _mb_substr($str, $start, $length, $encoding); 19 19 } 20 20 endif; 21 21 22 function _mb_substr( $str, $start, $length =null, $encoding=null ) {23 // the solution below ,works only for utf-8, so in case of a different22 function _mb_substr( $str, $start, $length = null, $encoding = null ) { 23 // the solution below works only for utf-8, so in case of a different 24 24 // charset, just use built-in substr 25 25 $charset = get_option( 'blog_charset' ); 26 if ( !in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) {27 return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length);26 if ( !in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 27 return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length); 28 28 } 29 29 // use the regex unicode support to separate the UTF-8 characters into an array 30 30 preg_match_all( '/./us', $str, $match ); 31 $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length );31 $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); 32 32 return implode( '', $chars ); 33 33 } 34 34 35 if ( !function_exists('mb_strlen') ): 36 function mb_strlen( $str, $encoding = null ) { 37 return _mb_strlen($str, $encoding); 38 } 39 endif; 40 41 function _mb_strlen( $str, $encoding = null ) { 42 // the solution below works only for utf-8, so in case of a different 43 // charset, just use built-in strlen 44 $charset = get_option( 'blog_charset' ); 45 if ( !in_array( $charset, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 46 return strlen( $str ); 47 } 48 // use the regex unicode support to separate the UTF-8 characters into an array 49 return preg_match_all( '/./us', $str, $match ); 50 } 51 35 52 if ( !function_exists('hash_hmac') ): 36 53 function hash_hmac($algo, $data, $key, $raw_output = false) { 37 54 return _hash_hmac($algo, $data, $key, $raw_output); -
wp-includes/post.php
2850 2850 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 2851 2851 $suffix = 2; 2852 2852 do { 2853 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2853 $slug = urldecode( $slug ); 2854 $length = min( 200, mb_strlen( $slug ) ); 2855 $alt_post_name = urlencode( mb_substr( $slug, 0, $length - ( strlen( $suffix ) + 1 ) ) . "-$suffix" ); 2854 2856 $post_name_check = $wpdb->get_var( $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) ); 2855 2857 $suffix++; 2856 2858 } while ( $post_name_check ); … … 2865 2867 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) { 2866 2868 $suffix = 2; 2867 2869 do { 2868 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2870 $slug = urldecode( $slug ); 2871 $length = min( 200, mb_strlen( $slug ) ); 2872 $alt_post_name = urlencode( mb_substr( $slug, 0, $length - ( strlen( $suffix ) + 1 ) ) . "-$suffix" ); 2869 2873 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_ID, $post_parent ) ); 2870 2874 $suffix++; 2871 2875 } while ( $post_name_check ); … … 2879 2883 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 2880 2884 $suffix = 2; 2881 2885 do { 2882 $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; 2886 $slug = urldecode( $slug ); 2887 $length = min( 200, mb_strlen( $slug ) ); 2888 $alt_post_name = urlencode( mb_substr( $slug, 0, $length - ( strlen( $suffix ) + 1 ) ) . "-$suffix" ); 2883 2889 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $alt_post_name, $post_type, $post_ID ) ); 2884 2890 $suffix++; 2885 2891 } while ( $post_name_check );