WordPress.org

Ready to get started?Download WordPress

Forums

Bug? add_post_meta / update_post_meta (2 posts)

  1. Kruncher
    Member
    Posted 3 years ago #

    I have a JSON encoded string $json_string which needs to be stored into the post meta data.

    Doing the following damages the JSON encoded data:

    add_post_meta($post_id, 'json-data', $json_string);

    After searching the Internet I found that somebody else had a similar issue, and it looks as though the following addresses the issue:

    add_post_meta($post_id, 'json-data', $wpdb->escape($json_string));

    3 Questions:

    #1) Is this a fault with WordPress?

    #2) Is the above safe? Is it likely to damage my clients data?

    #3) Could there be a security risk with the default "add_post_meta" functionality?

    Kind regards,
    Lea Hayes

  2. Baki Goxhaj
    Member
    Posted 3 years ago #

    Thanks for sharing this - I was having the same trouble. I will drop a line to wp-hacker's list and bring back what they say.

Topic Closed

This topic has been closed to new replies.

About this Topic