Make WordPress Core

Ticket #9064: 9064.2.diff

File 9064.2.diff, 3.2 KB (added by wonderboymusic, 11 years ago)
  • wp-includes/comment.php

    diff --git wp-includes/comment.php wp-includes/comment.php
    index d3d8db6..9987985 100644
    function pingback($content, $post_ID) { 
    18121812
    18131813        $pung = get_pung($post_ID);
    18141814
    1815         // Variables
    1816         $ltrs = '\w';
    1817         $gunk = '/#~:.?+=&%@!\-';
    1818         $punc = '.:?\-';
    1819         $any = $ltrs . $gunk . $punc;
    1820 
    18211815        // Step 1
    18221816        // Parsing the post, external links (if any) are stored in the $post_links array
    1823         // This regexp comes straight from phpfreaks.com
    1824         // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
    1825         preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
     1817        $post_links_temp = wp_extract_urls( $content );
    18261818
    18271819        // Step 2.
    18281820        // Walking thru the links array
    function pingback($content, $post_ID) { 
    18331825        // http://dummy-weblog.org/post.php
    18341826        // We don't wanna ping first and second types, even if they have a valid <link/>
    18351827
    1836         foreach ( (array) $post_links_temp[0] as $link_test ) :
     1828        foreach ( (array) $post_links_temp as $link_test ) :
    18371829                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
    18381830                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    18391831                        if ( $test = @parse_url($link_test) ) {
  • wp-includes/functions.php

    diff --git wp-includes/functions.php wp-includes/functions.php
    index 6d37ede..74d4a06 100644
    function xmlrpc_removepostdata( $content ) { 
    393393}
    394394
    395395/**
     396 * Use RegEx to extract URLs from arbitrary content
     397 *
     398 * @since 3.7.0
     399 *
     400 * @param string $content
     401 * @return array URLs found in passed string
     402 */
     403function wp_extract_urls( $content ) {
     404        preg_match_all(
     405                "#((?:[\w-]+://?|[\w\d]+[.])[^\s()<>]+[.](?:\([\w\d]+\)|(?:[^`!()\[\]{};:'\".,<>?«»“”‘’\s]|(?:[:]\d+)?/?)+))#",
     406                $content,
     407                $post_links
     408        );
     409
     410        $post_links = array_unique( array_map( 'html_entity_decode', $post_links[0] ) );
     411
     412        return array_values( $post_links );
     413}
     414
     415/**
    396416 * Check content for video and audio links to add as enclosures.
    397417 *
    398418 * Will not add enclosures that have already been added and will
    function do_enclose( $content, $post_ID ) { 
    417437
    418438        $pung = get_enclosed( $post_ID );
    419439
    420         $ltrs = '\w';
    421         $gunk = '/#~:.?+=&%@!\-';
    422         $punc = '.:?\-';
    423         $any = $ltrs . $gunk . $punc;
    424 
    425         preg_match_all( "{\b https? : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );
     440        $post_links_temp = wp_extract_urls( $content );
    426441
    427442        foreach ( $pung as $link_test ) {
    428                 if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
     443                if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post
    429444                        $mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $link_test ) . '%') );
    430445                        foreach ( $mids as $mid )
    431446                                delete_metadata_by_mid( 'post', $mid );
    432447                }
    433448        }
    434449
    435         foreach ( (array) $post_links_temp[0] as $link_test ) {
     450        foreach ( (array) $post_links_temp as $link_test ) {
    436451                if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
    437452                        $test = @parse_url( $link_test );
    438453                        if ( false === $test )