Ticket #8767: filters-speedup.patch
File filters-speedup.patch, 2.4 KB (added by , 16 years ago) |
---|
-
wp-includes/formatting.php
207 207 return ''; 208 208 } 209 209 210 // Don't bother if there are no specialchars - saves some processing 211 if ( !preg_match( '/[&<>"\']/', $string ) ) { 212 return $string; 213 } 214 215 // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() 210 216 if ( !$charset ) { 211 $alloptions = wp_load_alloptions(); 212 $charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; 217 static $_charset; 218 if ( !isset( $_charset ) ) { 219 $alloptions = wp_load_alloptions(); 220 $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; 221 } 222 $charset = $_charset; 213 223 } 214 224 if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) { 215 225 $charset = 'UTF-8'; … … 283 293 return ''; 284 294 } 285 295 296 // Don't bother if there are no entities - saves a lot of processing 297 if ( strpos( $string, '&' ) === false ) { 298 return $string; 299 } 300 286 301 // More complete than get_html_translation_table( HTML_SPECIALCHARS ) 287 302 $single = array( ''' => '\'', ''' => '\'' ); 288 303 $single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' ); … … 340 355 return ''; 341 356 } 342 357 343 if ( !in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { 358 // Store the site charset as a static to avoid multiple calls to get_option() 359 static $is_utf8; 360 if ( !isset( $is_utf8 ) ) { 361 $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); 362 } 363 if ( !$is_utf8 ) { 344 364 return $string; 345 365 } 346 366 367 // Check for support for utf8 in the installed PCRE library once and store the result in a static 368 static $utf8_pcre; 369 if ( !isset( $utf8_pcre ) ) { 370 $utf8_pcre = @preg_match( '/^./u', 'a' ); 371 } 372 // We can't demand utf8 in the PCRE installation, so just return the string in those cases 373 if ( !$utf8_pcre ) { 374 return $string; 375 } 376 347 377 // preg_match fails when it encounters invalid UTF8 in $string 348 if ( 1 === @preg_match( ' @^.@us', $string ) ) {378 if ( 1 === @preg_match( '/^./us', $string ) ) { 349 379 return $string; 350 380 } 351 381 382 // Attempt to strip the bad chars if requested (not recommended) 352 383 if ( $strip && function_exists( 'iconv' ) ) { 353 384 return iconv( 'utf-8', 'utf-8', $string ); 354 } else {355 return '';356 385 } 386 387 return ''; 357 388 } 358 389 359 390 /**