Make WordPress Core


Ignore:
Timestamp:
03/02/2006 02:47:36 AM (19 years ago)
Author:
ryan
Message:

DB escaping in fix_attachment_links(). #2434

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r3570 r3586  
    106106    global $wp_rewrite;
    107107
    108     $post = & get_post($post_ID);
     108    $post = & get_post($post_ID, ARRAY_A);
    109109
    110110    $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
    111111
    112112    // See if we have any rel="attachment" links
    113     if ( 0 == preg_match_all($search, $post->post_content, $anchor_matches, PREG_PATTERN_ORDER) )
     113    if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
    114114        return;
    115115
     
    123123
    124124        // While we have the attachment ID, let's adopt any orphans.
    125         $attachment = & get_post($id);
    126         if ( ! is_object(get_post($attachment->post_parent)) ) {
    127             $attachment->post_parent = $post_ID;
     125        $attachment = & get_post($id, ARRAY_A);
     126        if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
     127            $attachment['post_parent'] = $post_ID;
     128            // Escape data pulled from DB.
     129            $attachment = add_magic_quotes($attachment);
    128130            wp_update_post($attachment);
    129131        }
     
    134136    }
    135137
    136     $post->post_content = str_replace($post_search, $post_replace, $post->post_content);
     138    $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
     139
     140    // Escape data pulled from DB.
     141    $post = add_magic_quotes($post);
    137142
    138143    return wp_update_post($post);
Note: See TracChangeset for help on using the changeset viewer.