Changeset 52010 for trunk/tests/phpunit/tests/formatting/escUrl.php
- Timestamp:
- 11/04/2021 03:22:47 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/escUrl.php
r51623 r52010 9 9 * @ticket 23605 10 10 */ 11 function test_spaces() {11 public function test_spaces() { 12 12 $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) ); 13 13 $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) ); … … 20 20 } 21 21 22 function test_bad_characters() {22 public function test_bad_characters() { 23 23 $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); 24 24 $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) ); … … 34 34 } 35 35 36 function test_relative() {36 public function test_relative() { 37 37 $this->assertSame( '/example.php', esc_url( '/example.php' ) ); 38 38 $this->assertSame( 'example.php', esc_url( 'example.php' ) ); … … 41 41 } 42 42 43 function test_all_url_parts() {43 public function test_all_url_parts() { 44 44 $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment'; 45 45 … … 61 61 } 62 62 63 function test_bare() {63 public function test_bare() { 64 64 $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); 65 65 $this->assertSame( 'http://example.com', esc_url( 'example.com' ) ); … … 69 69 } 70 70 71 function test_encoding() {71 public function test_encoding() { 72 72 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); 73 73 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); … … 82 82 } 83 83 84 function test_protocol() {84 public function test_protocol() { 85 85 $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) ); 86 86 $this->assertSame( '', esc_url( 'nasty://example.com/' ) ); … … 147 147 * @ticket 23187 148 148 */ 149 function test_protocol_case() {149 public function test_protocol_case() { 150 150 $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) ); 151 151 $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) ); 152 152 } 153 153 154 function test_display_extras() {154 public function test_display_extras() { 155 155 $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); 156 156 $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) ); 157 157 } 158 158 159 function test_non_ascii() {159 public function test_non_ascii() { 160 160 $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); 161 161 $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) ); … … 163 163 } 164 164 165 function test_feed() {165 public function test_feed() { 166 166 $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) ); 167 167 $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) ); … … 174 174 * @ticket 16859 175 175 */ 176 function test_square_brackets() {176 public function test_square_brackets() { 177 177 $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) ); 178 178 $this->assertSame( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) ); … … 189 189 * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding 190 190 */ 191 function test_reserved_characters() {191 public function test_reserved_characters() { 192 192 $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;="; 193 193 $this->assertSame( $url, esc_url_raw( $url ) ); … … 197 197 * @ticket 21974 198 198 */ 199 function test_protocol_relative_with_colon() {199 public function test_protocol_relative_with_colon() { 200 200 $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); 201 201 } … … 204 204 * @ticket 31632 205 205 */ 206 function test_mailto_with_newline() {206 public function test_mailto_with_newline() { 207 207 $body = <<<EOT 208 208 Hi there, … … 219 219 * @ticket 31632 220 220 */ 221 function test_mailto_in_http_url_with_newline() {221 public function test_mailto_in_http_url_with_newline() { 222 222 $body = <<<EOT 223 223 Hi there, … … 234 234 * @ticket 23605 235 235 */ 236 function test_mailto_with_spaces() {236 public function test_mailto_with_spaces() { 237 237 $body = 'Hi there, I thought you might want to sign up for this newsletter'; 238 238 … … 245 245 * @ticket 28015 246 246 */ 247 function test_invalid_charaters() {247 public function test_invalid_charaters() { 248 248 $this->assertEmpty( esc_url_raw( '"^<>{}`' ) ); 249 249 } … … 252 252 * @ticket 34202 253 253 */ 254 function test_ipv6_hosts() {254 public function test_ipv6_hosts() { 255 255 $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) ); 256 256 $this->assertSame( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) );
Note: See TracChangeset
for help on using the changeset viewer.