Changeset 53562 for trunk/tests/phpunit/tests/formatting/escUrl.php
- Timestamp:
- 06/23/2022 08:27:34 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/escUrl.php
r53455 r53562 8 8 /** 9 9 * @ticket 23605 10 * 11 * @covers ::esc_url 10 12 */ 11 13 public function test_spaces() { … … 20 22 } 21 23 24 /** 25 * @covers ::esc_url 26 */ 22 27 public function test_bad_characters() { 23 28 $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); … … 34 39 } 35 40 41 /** 42 * @covers ::esc_url 43 */ 36 44 public function test_relative() { 37 45 $this->assertSame( '/example.php', esc_url( '/example.php' ) ); … … 41 49 } 42 50 51 /** 52 * @covers ::esc_url 53 * @covers ::esc_url_raw 54 */ 43 55 public function test_all_url_parts() { 44 56 $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment'; … … 57 69 parse_url( $url ) 58 70 ); 59 $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', sanitize_url( $url ) );71 $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url_raw( $url ) ); 60 72 $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) ); 61 73 } 62 74 75 /** 76 * @covers ::esc_url 77 */ 63 78 public function test_bare() { 64 79 $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); … … 69 84 } 70 85 86 /** 87 * @covers ::esc_url 88 * @covers ::esc_url_raw 89 */ 71 90 public function test_encoding() { 72 $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );73 $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );74 $this->assertSame( 'http://example.com?foo=1&bar=2', sanitize_url( 'http://example.com?foo=1&bar=2' ) );91 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); 92 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); 93 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); 75 94 76 95 $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); … … 82 101 } 83 102 103 /** 104 * @covers ::esc_url 105 * @covers ::wp_allowed_protocols 106 */ 84 107 public function test_protocol() { 85 108 $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) ); … … 146 169 /** 147 170 * @ticket 23187 171 * 172 * @covers ::esc_url 148 173 */ 149 174 public function test_protocol_case() { … … 152 177 } 153 178 179 /** 180 * @covers ::esc_url 181 */ 154 182 public function test_display_extras() { 155 183 $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); … … 157 185 } 158 186 187 /** 188 * @covers ::esc_url 189 */ 159 190 public function test_non_ascii() { 160 191 $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); … … 163 194 } 164 195 196 /** 197 * @covers ::esc_url 198 */ 165 199 public function test_feed() { 166 200 $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) ); … … 173 207 /** 174 208 * @ticket 16859 209 * 210 * @covers ::esc_url 175 211 */ 176 212 public function test_square_brackets() { … … 188 224 /** 189 225 * Courtesy of http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding 226 * 227 * @covers ::esc_url_raw 190 228 */ 191 229 public function test_reserved_characters() { 192 230 $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;="; 193 $this->assertSame( $url, sanitize_url( $url ) );231 $this->assertSame( $url, esc_url_raw( $url ) ); 194 232 } 195 233 196 234 /** 197 235 * @ticket 21974 236 * 237 * @covers ::esc_url 198 238 */ 199 239 public function test_protocol_relative_with_colon() { … … 203 243 /** 204 244 * @ticket 31632 245 * 246 * @covers ::esc_url 205 247 */ 206 248 public function test_mailto_with_newline() { … … 218 260 /** 219 261 * @ticket 31632 262 * 263 * @covers ::esc_url 220 264 */ 221 265 public function test_mailto_in_http_url_with_newline() { … … 233 277 /** 234 278 * @ticket 23605 279 * 280 * @covers ::esc_url 235 281 */ 236 282 public function test_mailto_with_spaces() { … … 244 290 /** 245 291 * @ticket 28015 292 * 293 * @covers ::esc_url_raw 246 294 */ 247 295 public function test_invalid_charaters() { 248 $this->assertEmpty( sanitize_url( '"^<>{}`' ) );296 $this->assertEmpty( esc_url_raw( '"^<>{}`' ) ); 249 297 } 250 298 251 299 /** 252 300 * @ticket 34202 301 * 302 * @covers ::esc_url 253 303 */ 254 304 public function test_ipv6_hosts() {
Note: See TracChangeset
for help on using the changeset viewer.