Make WordPress Core

Changeset 29756


Ignore:
Timestamp:
09/23/2014 02:49:22 AM (12 years ago)
Author:
wonderboymusic
Message:

wp_extract_urls() needs to also grab URLs with query strings and hashes.

Updates unit test.

Props hauvong, dlh.
Fixes #29314.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r29344 r29756  
    458458function wp_extract_urls( $content ) {
    459459        preg_match_all(
    460                 "#("
     460                "#([\"']?)("
    461461                        . "(?:([\w-]+:)?//?)"
    462462                        . "[^\s()<>]+"
    … …  
    465465                                . "\([\w\d]+\)|"
    466466                                . "(?:"
    467                                         . "[^`!()\[\]{};:'\".,<>?«»“”‘’\s]|"
     467                                        . "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|"
    468468                                        . "(?:[:]\d+)?/?"
    469469                                . ")+"
    470470                        . ")"
    471                 . ")#",
     471                . ")\\1#",
    472472                $content,
    473473                $post_links
    474474        );
    475475
    476         $post_links = array_unique( array_map( 'html_entity_decode', $post_links[0] ) );
     476        $post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
    477477
    478478        return array_values( $post_links );
  • trunk/tests/phpunit/tests/functions.php

    r29342 r29756  
    422422                        'http://украина.icom.museum',
    423423                        'http://việtnam.icom.museum',
    424                         'ftp://127.0.0.1/'
     424                        'ftp://127.0.0.1/',
     425                        'http://www.woo.com/video?v=exvUH2qKLTU',
     426                        'http://taco.com?burrito=enchilada#guac'
    425427                );
    426428
    … …  
    482484                        http://việtnam.icom.museum
    483485                        ftp://127.0.0.1/
     486                        http://www.woo.com/video?v=exvUH2qKLTU
     487
     488                        http://taco.com?burrito=enchilada#guac
    484489                ";
    485490
Note: See TracChangeset for help on using the changeset viewer.