Make WordPress Core

Changeset 28882


Ignore:
Timestamp:
06/28/2014 04:15:30 AM (10 years ago)
Author:
wonderboymusic
Message:

wp_extract_urls() should not match dates.

Updates unit tests.

Props hinnerk, sergej.mueller.
Fixes #28222.

Location:
trunk
Files:
2 edited

Legend:

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

    r28858 r28882  
    442442function wp_extract_urls( $content ) {
    443443    preg_match_all(
    444         "#((?:[\w-]+://?|[\w\d]+[.])[^\s()<>]+[.](?:\([\w\d]+\)|(?:[^`!()\[\]{};:'\".,<>?«»“”‘’\s]|(?:[:]\d+)?/?)+))#",
     444        "#("
     445            . "(?: ([\w-]+:)?//? )"
     446            . "[^\s()<>]+"
     447            . "[.]"
     448            . "(?:"
     449                . "\([\w\d]+\) |"
     450                . "(?:"
     451                    . "[^`!()\[\]{};:'\".,<>?«»“”‘’\s] |"
     452                    . "(?: [:]\d+ )?/?"
     453                . ")+"
     454            . ")"
     455        . ")#x",
    445456        $content,
    446457        $post_links
  • trunk/tests/phpunit/tests/functions.php

    r25313 r28882  
    371371            'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html',
    372372            'http://this.com',
     373            'http://127.0.0.1',
    373374            'http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437',
    374375            'http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html',
     
    420421            'http://türkiye.icom.museum',
    421422            'http://украина.icom.museum',
    422             'http://việtnam.icom.museum'
     423            'http://việtnam.icom.museum',
     424            'ftp://127.0.0.1/'
    423425        );
    424426
     
    427429
    428430            http://this.com
     431
     432            http://127.0.0.1
    429433
    430434            http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437
     
    477481            http://украина.icom.museum
    478482            http://việtnam.icom.museum
     483            ftp://127.0.0.1/
    479484        ";
    480485
     
    494499        $blob ="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
    495500            incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua.
    496             Ut http://this.com enim ad minim veniam, quis nostrud exercitation ullamco
     501            Ut http://this.com enim ad minim veniam, quis nostrud exercitation 16.06. to 18.06.2014 ullamco http://127.0.0.1
    497502            laboris nisi ut aliquip ex http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437 ea
    498503            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
     
    503508        $this->assertNotEmpty( $urls );
    504509        $this->assertInternalType( 'array', $urls );
    505         $this->assertCount( 7, $urls );
    506         $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls );
     510        $this->assertCount( 8, $urls );
     511        $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls );
    507512
    508513        $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
    509514            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.
    510             Ut <a href="http://this.com">&amp;3640i6p1yi499</a> enim ad minim veniam, quis nostrud exercitation ullamco
     515            Ut <a href="http://this.com">&amp;3640i6p1yi499</a> enim ad minim veniam, quis nostrud exercitation 16.06. to 18.06.2014 ullamco <a href="http://127.0.0.1">localhost</a>
    511516            laboris nisi ut aliquip ex <a href="http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&amp;2134362574863.437">343462^</a> ea
    512517            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
     
    517522        $this->assertNotEmpty( $urls );
    518523        $this->assertInternalType( 'array', $urls );
    519         $this->assertCount( 7, $urls );
    520         $this->assertEquals( array_slice( $original_urls, 0, 7 ), $urls );
     524        $this->assertCount( 8, $urls );
     525        $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls );
    521526    }
    522527}
Note: See TracChangeset for help on using the changeset viewer.