Ticket #9064: comments.new_rx.diff

File comments.new_rx.diff, 1.2 KB (added by sirzooro, 4 years ago)

Patch with new rx (slightly improved vs proposed earlier)

  • comment.php

    old new  
    13941394 
    13951395        $pung = get_pung($post_ID); 
    13961396 
    1397         // Variables 
    1398         $ltrs = '\w'; 
    1399         $gunk = '/#~:.?+=&%@!\-'; 
    1400         $punc = '.:?\-'; 
    1401         $any = $ltrs . $gunk . $punc; 
    1402  
    14031397        // Step 1 
    14041398        // Parsing the post, external links (if any) are stored in the $post_links array 
    1405         // This regexp comes straight from phpfreaks.com 
    1406         // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php 
    1407         preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp); 
     1399        preg_match_all( '/\bhref\s*=["\'\s]*http([^"\'\s]+)/i', $content, $post_links_temp ); 
    14081400 
    14091401        // Step 2. 
    14101402        // Walking thru the links array 
     
    14151407        // http://dummy-weblog.org/post.php 
    14161408        // We don't wanna ping first and second types, even if they have a valid <link/> 
    14171409 
    1418         foreach ( (array) $post_links_temp[0] as $link_test ) : 
     1410        foreach ( (array) $post_links_temp[1] as $link_test ) : 
    14191411                if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself 
    14201412                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. 
    14211413                        if ( $test = @parse_url($link_test) ) {