| 379 | |
| 380 | /** |
| 381 | * @ticket 9064 |
| 382 | */ |
| 383 | function test_wp_extract_urls() { |
| 384 | $original_urls = array( |
| 385 | 'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html', |
| 386 | 'http://this.com', |
| 387 | 'http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437', |
| 388 | 'http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html', |
| 389 | 'http://wordpress-core.com:8080/', |
| 390 | 'http://www.website.com:5000', |
| 391 | 'http://wordpress-core/?346236346326&2134362574863.437', |
| 392 | 'http://افغانستا.icom.museum', |
| 393 | 'http://الجزائر.icom.museum', |
| 394 | 'http://österreich.icom.museum', |
| 395 | 'http://বাংলাদেশ.icom.museum', |
| 396 | 'http://беларусь.icom.museum', |
| 397 | 'http://belgië.icom.museum', |
| 398 | 'http://българия.icom.museum', |
| 399 | 'http://تشادر.icom.museum', |
| 400 | 'http://中国.icom.museum', |
| 401 | #'http://القمر.icom.museum', // Comoros http://القمر.icom.museum |
| 402 | #'http://κυπρος.icom.museum', Cyprus http://κυπρος.icom.museum |
| 403 | 'http://českárepublika.icom.museum', |
| 404 | #'http://مصر.icom.museum', // Egypt http://مصر.icom.museum |
| 405 | 'http://ελλάδα.icom.museum', |
| 406 | 'http://magyarország.icom.museum', |
| 407 | 'http://ísland.icom.museum', |
| 408 | 'http://भारत.icom.museum', |
| 409 | 'http://ايران.icom.museum', |
| 410 | 'http://éire.icom.museum', |
| 411 | 'http://איקו״ם.ישראל.museum', |
| 412 | 'http://日本.icom.museum', |
| 413 | 'http://الأردن.icom.museum', |
| 414 | 'http://қазақстан.icom.museum', |
| 415 | 'http://한국.icom.museum', |
| 416 | 'http://кыргызстан.icom.museum', |
| 417 | 'http://ລາວ.icom.museum', |
| 418 | 'http://لبنان.icom.museum', |
| 419 | 'http://македонија.icom.museum', |
| 420 | #'http://موريتانيا.icom.museum', // Mauritania http://موريتانيا.icom.museum |
| 421 | 'http://méxico.icom.museum', |
| 422 | 'http://монголулс.icom.museum', |
| 423 | #'http://المغرب.icom.museum', // Morocco http://المغرب.icom.museum |
| 424 | 'http://नेपाल.icom.museum', |
| 425 | #'http://عمان.icom.museum', // Oman http://عمان.icom.museum |
| 426 | 'http://قطر.icom.museum', |
| 427 | 'http://românia.icom.museum', |
| 428 | 'http://россия.иком.museum', |
| 429 | 'http://србијаицрнагора.иком.museum', |
| 430 | 'http://இலங்கை.icom.museum', |
| 431 | 'http://españa.icom.museum', |
| 432 | 'http://ไทย.icom.museum', |
| 433 | 'http://تونس.icom.museum', |
| 434 | 'http://türkiye.icom.museum', |
| 435 | 'http://украина.icom.museum', |
| 436 | 'http://việtnam.icom.museum' |
| 437 | ); |
| 438 | |
| 439 | $blob =" |
| 440 | http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html |
| 441 | |
| 442 | http://this.com |
| 443 | |
| 444 | http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437 |
| 445 | |
| 446 | http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html |
| 447 | |
| 448 | http://wordpress-core.com:8080/ |
| 449 | |
| 450 | http://www.website.com:5000 |
| 451 | |
| 452 | http://wordpress-core/?346236346326&2134362574863.437 |
| 453 | |
| 454 | http://افغانستا.icom.museum |
| 455 | http://الجزائر.icom.museum |
| 456 | http://österreich.icom.museum |
| 457 | http://বাংলাদেশ.icom.museum |
| 458 | http://беларусь.icom.museum |
| 459 | http://belgië.icom.museum |
| 460 | http://българия.icom.museum |
| 461 | http://تشادر.icom.museum |
| 462 | http://中国.icom.museum |
| 463 | http://českárepublika.icom.museum |
| 464 | http://ελλάδα.icom.museum |
| 465 | http://magyarország.icom.museum |
| 466 | http://ísland.icom.museum |
| 467 | http://भारत.icom.museum |
| 468 | http://ايران.icom.museum |
| 469 | http://éire.icom.museum |
| 470 | http://איקו״ם.ישראל.museum |
| 471 | http://日本.icom.museum |
| 472 | http://الأردن.icom.museum |
| 473 | http://қазақстан.icom.museum |
| 474 | http://한국.icom.museum |
| 475 | http://кыргызстан.icom.museum |
| 476 | http://ລາວ.icom.museum |
| 477 | http://لبنان.icom.museum |
| 478 | http://македонија.icom.museum |
| 479 | http://méxico.icom.museum |
| 480 | http://монголулс.icom.museum |
| 481 | http://नेपाल.icom.museum |
| 482 | http://قطر.icom.museum |
| 483 | http://românia.icom.museum |
| 484 | http://россия.иком.museum |
| 485 | http://србијаицрнагора.иком.museum |
| 486 | http://இலங்கை.icom.museum |
| 487 | http://españa.icom.museum |
| 488 | http://ไทย.icom.museum |
| 489 | http://تونس.icom.museum |
| 490 | http://türkiye.icom.museum |
| 491 | http://украина.icom.museum |
| 492 | http://việtnam.icom.museum |
| 493 | "; |
| 494 | |
| 495 | $urls = wp_extract_urls( $blob ); |
| 496 | print_r( $urls ); |
| 497 | $this->assertNotEmpty( $urls ); |
| 498 | $this->assertInternalType( 'array', $urls ); |
| 499 | $this->assertCount( count( $original_urls ), $urls ); |
| 500 | $this->assertEquals( $original_urls, $urls ); |
| 501 | |
| 502 | $exploded = array_values( array_filter( array_map( 'trim', explode( "\n", $blob ) ) ) ); |
| 503 | // wp_extract_urls calls html_entity_decode |
| 504 | $decoded = array_map( 'html_entity_decode', $exploded ); |
| 505 | |
| 506 | $this->assertEquals( $decoded, $urls ); |
| 507 | $this->assertEquals( $original_urls, $decoded ); |
| 508 | |
| 509 | $blob ="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor |
| 510 | incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua. |
| 511 | Ut http://this.com enim ad minim veniam, quis nostrud exercitation ullamco |
| 512 | laboris nisi ut aliquip ex http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437 ea |
| 513 | commodo consequat. http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html Duis aute irure dolor in reprehenderit in voluptate |
| 514 | velit esse http://wordpress-core.com:8080/ cillum dolore eu fugiat nulla <A href=\"http://www.website.com:5000\">http://www.website.com:5000</B> pariatur. Excepteur sint occaecat cupidatat non proident, |
| 515 | sunt in culpa qui officia deserunt mollit http://wordpress-core/?346236346326&2134362574863.437 anim id est laborum."; |
| 516 | |
| 517 | $urls = wp_extract_urls( $blob ); |
| 518 | $this->assertNotEmpty( $urls ); |
| 519 | $this->assertInternalType( 'array', $urls ); |
| 520 | $this->assertCount( 7, $urls ); |
| 521 | $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls ); |
| 522 | |
| 523 | $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor |
| 524 | incididunt ut labore <a href="http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> et dolore magna aliqua. |
| 525 | Ut <a href="http://this.com">&3640i6p1yi499</a> enim ad minim veniam, quis nostrud exercitation ullamco |
| 526 | laboris nisi ut aliquip ex <a href="http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437">343462^</a> ea |
| 527 | commodo consequat. <a href="http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> Duis aute irure dolor in reprehenderit in voluptate |
| 528 | velit esse <a href="http://wordpress-core.com:8080/">-3-4--321-64-4@#!$^$!@^@^</a> cillum dolore eu <A href="http://www.website.com:5000">http://www.website.com:5000</B> fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, |
| 529 | sunt in culpa qui officia deserunt mollit <a href="http://wordpress-core/?346236346326&2134362574863.437">)(*&^%$</a> anim id est laborum.'; |
| 530 | |
| 531 | $urls = wp_extract_urls( $blob ); |
| 532 | print_r( $urls ); |
| 533 | $this->assertNotEmpty( $urls ); |
| 534 | $this->assertInternalType( 'array', $urls ); |
| 535 | $this->assertCount( 7, $urls ); |
| 536 | $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls ); |
| 537 | } |