WordPress.org

Make WordPress Core

Changeset 12198


Ignore:
Timestamp:
11/17/2009 07:25:01 PM (9 years ago)
Author:
ryan
Message:

Use preg_replace_callback to eliminate eval. Props BenBE1987. fixes #10896

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r12110 r12198  
    714714 */
    715715function _fix_attachment_links( $post_ID ) {
     716    global $_fix_attachment_link_id;
    716717
    717718    $post = & get_post( $post_ID, ARRAY_A );
     
    741742
    742743        $post_search[$i] = $anchor;
    743         $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
     744         $_fix_attachment_link_id = $id;
     745        $post_replace[$i] = preg_replace_callback( "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
    744746        ++$i;
    745747    }
     
    751753
    752754    return wp_update_post( $post);
     755}
     756
     757function _fix_attachment_links_replace_cb($match) {
     758        global $_fix_attachment_link_id;
     759        return stripslashes( 'href='.$m[1] ).get_attachment_link( $_fix_attachment_link_id ).stripslashes( $m[1] );
    753760}
    754761
Note: See TracChangeset for help on using the changeset viewer.