Changeset 11380 for trunk/wp-includes/formatting.php
- Timestamp:
- 05/18/2009 03:11:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r11345 r11380 214 214 * @return string The encoded text with HTML entities. 215 215 */ 216 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {216 function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { 217 217 $string = (string) $string; 218 218 … … 287 287 * 288 288 * @param string $string The text which is to be decoded. 289 * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.289 * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. 290 290 * @return string The decoded text without HTML entities. 291 291 */ … … 302 302 } 303 303 304 // Match the previous behaviour of wp_specialchars() when the $quote_style is not an accepted value304 // Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value 305 305 if ( empty( $quote_style ) ) { 306 306 $quote_style = ENT_NOQUOTES; … … 2075 2075 function esc_js( $text ) { 2076 2076 $safe_text = wp_check_invalid_utf8( $text ); 2077 $safe_text = wp_specialchars( $safe_text, ENT_COMPAT );2077 $safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); 2078 2078 $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); 2079 2079 $safe_text = preg_replace( "/\r?\n/", "\\n", addslashes( $safe_text ) ); … … 2099 2099 2100 2100 /** 2101 * Escaping for HTML attributes.2101 * Escaping for HTML blocks. 2102 2102 * 2103 2103 * @since 2.8.0 … … 2106 2106 * @return string 2107 2107 */ 2108 function esc_html( $text ) { 2109 $safe_text = wp_check_invalid_utf8( $text ); 2110 $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 2111 return apply_filters( 'esc_html', $safe_text, $text ); 2112 return $text; 2113 } 2114 2115 /** 2116 * Escaping for HTML blocks 2117 * @deprecated 2.8.0 2118 * @see esc_html() 2119 */ 2120 function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { 2121 if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args 2122 $args = func_get_args(); 2123 return call_user_func_array( '_wp_specialchars', $args ); 2124 } else { 2125 return esc_html( $string ); 2126 } 2127 } 2128 2129 /** 2130 * Escaping for HTML attributes. 2131 * 2132 * @since 2.8.0 2133 * 2134 * @param string $text 2135 * @return string 2136 */ 2108 2137 function esc_attr( $text ) { 2109 2138 $safe_text = wp_check_invalid_utf8( $text ); 2110 $safe_text = wp_specialchars( $safe_text, ENT_QUOTES );2139 $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 2111 2140 return apply_filters( 'attribute_escape', $safe_text, $text ); 2112 2141 } … … 2225 2254 $value = wp_filter_post_kses( $value ); // calls stripslashes then addslashes 2226 2255 $value = stripslashes($value); 2227 $value = wp_specialchars( $value );2256 $value = esc_html( $value ); 2228 2257 break; 2229 2258 … … 2299 2328 * Callback function used by preg_replace. 2300 2329 * 2301 * @uses wp_specialcharsto format the $matches text.2330 * @uses esc_html to format the $matches text. 2302 2331 * @since 2.3.0 2303 2332 * 2304 2333 * @param array $matches Populated by matches to preg_replace. 2305 * @return string The text returned after wp_specialcharsif needed.2334 * @return string The text returned after esc_html if needed. 2306 2335 */ 2307 2336 function wp_pre_kses_less_than_callback( $matches ) { 2308 2337 if ( false === strpos($matches[0], '>') ) 2309 return wp_specialchars($matches[0]);2338 return esc_html($matches[0]); 2310 2339 return $matches[0]; 2311 2340 }
Note: See TracChangeset
for help on using the changeset viewer.