Make WordPress Core

Ticket #9064: 9064.diff

File 9064.diff, 4.0 KB (added by wonderboymusic, 12 years ago)
  • wordpress/wp-includes/comment.php

    diff --git wordpress/wp-includes/comment.php wordpress/wp-includes/comment.php
    index 4f60206..973e2a6 100644
    function pingback($content, $post_ID) { 
    18151815
    18161816        $pung = get_pung($post_ID);
    18171817
    1818         // Variables
    1819         $ltrs = '\w';
    1820         $gunk = '/#~:.?+=&%@!\-';
    1821         $punc = '.:?\-';
    1822         $any = $ltrs . $gunk . $punc;
    1823 
    18241818        // Step 1
    18251819        // Parsing the post, external links (if any) are stored in the $post_links array
    1826         // This regexp comes straight from phpfreaks.com
    1827         // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
    1828         preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
     1820        $post_links_temp = wp_extract_urls( $content );
    18291821
    18301822        // Step 2.
    18311823        // Walking thru the links array
    function pingback($content, $post_ID) { 
    18361828        // http://dummy-weblog.org/post.php
    18371829        // We don't wanna ping first and second types, even if they have a valid <link/>
    18381830
    1839         foreach ( (array) $post_links_temp[0] as $link_test ) :
     1831        foreach ( (array) $post_links_temp as $link_test ) :
    18401832                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
    18411833                                && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
    18421834                        if ( $test = @parse_url($link_test) ) {
  • wordpress/wp-includes/functions.php

    diff --git wordpress/wp-includes/functions.php wordpress/wp-includes/functions.php
    index 5e0841c..76bf0b1 100644
    function xmlrpc_removepostdata( $content ) { 
    393393}
    394394
    395395/**
     396 * Use RegEx to extract URLs from arbitrary content
     397 *
     398 * @since 3.6.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 http : [$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 )
    function get_temp_dir() { 
    14371452/**
    14381453 * Determine if a directory is writable.
    14391454 *
    1440  * This function is used to work around certain ACL issues 
     1455 * This function is used to work around certain ACL issues
    14411456 * in PHP primarily affecting Windows Servers.
    14421457 *
    14431458 * @see win_is_writable()
    function wp_is_writable( $path ) { 
    14571472/**
    14581473 * Workaround for Windows bug in is_writable() function
    14591474 *
    1460  * PHP has issues with Windows ACL's for determine if a 
     1475 * PHP has issues with Windows ACL's for determine if a
    14611476 * directory is writable or not, this works around them by
    14621477 * checking the ability to open files rather than relying
    14631478 * upon PHP to interprate the OS ACL.