Ticket #32008: 32008.3.diff
| File 32008.3.diff, 4.5 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/formatting.php
3145 3145 } 3146 3146 3147 3147 /** 3148 * Wrapper for esc_url 3149 * 3150 * @since 4.3 3151 * 3152 * @uses esc_url() 3153 * 3154 * @param string $url The URL to be cleaned. 3155 * @param array $protocols Optional. An array of acceptable protocols. 3156 * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set. 3157 * @param string $_context Private. Use esc_url_raw() for database usage. 3158 * @return string The cleaned $url after the 'clean_url' filter is applied. 3159 */ 3160 function echo_url( $url, $protocols = null, $_context = 'display' ) { 3161 echo esc_url( $url, $protocols , $_context ); 3162 } 3163 3164 /** 3148 3165 * Performs esc_url() for database usage. 3149 3166 * 3150 3167 * @since 2.8.0 … … 3230 3247 return apply_filters( 'esc_html', $safe_text, $text ); 3231 3248 } 3232 3249 3250 3233 3251 /** 3252 * Wrapper for esc_html() 3253 * 3254 * @since 4.3 3255 * @uses esc_html() 3256 * 3257 * @param string $text 3258 */ 3259 function echo_html( $text ) { 3260 echo esc_html( $text ); 3261 } 3262 3263 /** 3234 3264 * Escaping for HTML attributes. 3235 3265 * 3236 3266 * @since 2.8.0 … … 3256 3286 } 3257 3287 3258 3288 /** 3289 * Wrapper for esc_attr 3290 * 3291 * @since 4.3 3292 * @uses esc_attr 3293 * 3294 * @param $text 3295 */ 3296 function echo_attr( $text ) { 3297 echo esc_attr( $text ); 3298 } 3299 3300 /** 3259 3301 * Escaping for textarea values. 3260 3302 * 3261 3303 * @since 3.1.0 -
tests/phpunit/tests/formatting/EscAttr.php
29 29 $out = esc_attr( 'foo & bar &baz; '' ); 30 30 $this->assertEquals( "foo & bar &baz; '", $out ); 31 31 } 32 33 /** 34 * Confirm output for esc_attr and echo_attr match 35 * @ticket 32008 36 * @dataProvider data_attrs_list 37 */ 38 function test_echo_attr_equals_esc_attr( $input ) { 39 40 $esc_attr = esc_attr( $input ); 41 42 ob_start(); 43 echo_attr( $input ); 44 $echo_attr = ob_get_clean(); 45 46 $this->assertEquals( $esc_attr , $echo_attr ); 47 } 48 49 function data_attrs_list() { 50 return array( 51 array( '"double quotes"' ), 52 array( "'single quotes'" ), 53 array( 'foo & bar &baz; '' ), 54 ); 55 } 32 56 } -
tests/phpunit/tests/formatting/EscHtml.php
37 37 $res = '& £ " &'; 38 38 $this->assertEquals( $res, esc_html($source) ); 39 39 } 40 41 /** 42 * Make sure esc_html output matches echo_html 43 * @ticket 32008 44 * @dataProvider data_html_to_escape 45 */ 46 function test_echo_html_equals_esc_html( $input ){ 47 $output_esc_html = esc_html( $input ); 48 49 ob_start(); 50 echo_html( $input ); 51 $output_echo_html = ob_get_clean(); 52 53 $this->assertEquals( $output_esc_html, $output_echo_html ); 54 } 55 56 function data_html_to_escape() { 57 return array( 58 array( 'The quick brown fox.' ), 59 array( 'http://localhost/trunk/wp-login.php?action=logout&_wpnonce=cd57d75985' ), 60 array( "SELECT meta_key, meta_value FROM wp_trunk_sitemeta WHERE meta_key IN ('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled') AND site_id = 1"), 61 array( 'penn & teller & at&t' ), 62 array( 'this > that < that <randomhtml />' ), 63 array( '& £ " &' ), 64 ); 65 } 40 66 } -
tests/phpunit/tests/formatting/EscUrl.php
68 68 function test_protocol_relative_with_colon() { 69 69 $this->assertEquals( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); 70 70 } 71 72 /** 73 * @ticket 32008 74 * @dataProvider data_url_list 75 */ 76 function test_esc_url_matches_echo_url( $input ) { 77 78 $esc_url = esc_url( $input ); 79 80 ob_start(); 81 echo_url( $input ); 82 $echo_url = ob_get_clean(); 83 84 $this->assertEquals( $esc_url, $echo_url ); 85 } 86 87 function data_url_list() { 88 return array( 89 array('http://example.com/'), 90 array('http://example.com/Mr WordPress'), 91 array('//example.com/'), 92 ); 93 } 71 94 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)