[wp-hackers] add_post_meta won't save unescaped data. Why?
Baki Goxhaj
banago at gmail.com
Wed Jan 26 08:28:36 UTC 2011
Thanks for pointing that out Dion.
However, even though it expects slashed meta_key, it saves the key as it is
given. At the same time it does not save the $meta_value at all unless it is
escaped. Is stripslashes_deep() causing that?
45 <http://core.trac.wordpress.org/browser/trunk/wp-includes/meta.php#L45>
// expected_slashed
($meta_key)46<http://core.trac.wordpress.org/browser/trunk/wp-includes/meta.php#L46>
$meta_key =
stripslashes($meta_key);47<http://core.trac.wordpress.org/browser/trunk/wp-includes/meta.php#L47>
$meta_value = stripslashes_deep($meta_value);
Kindly,
Baki Goxhaj
www.wplancer.com | www.banago.info | proverbhunter.com
On 25 January 2011 23:13, Dion Hulse (dd32) <wordpress at dd32.id.au> wrote:
> Unfortunately all the metadata API's expect slashed input data:
> http://core.trac.wordpress.org/browser/trunk/wp-includes/meta.php#L45
>
> I'm not sure why that was carried over into add_metadata() when it was
> implemented, Ideally it should've stayed in add_post_meta() and friends..
>
> But there you have it, It's yet another "backwards compatible" feature :)
>
>
> On Wed, 26 Jan 2011 05:03:42 +1100, Baki Goxhaj <banago at gmail.com> wrote:
>
> Hi Hackers,
>>
>> So, I was trying to insert some meta data to a post inserted by
>> wp_insert_post. It would not save the metadata and I found this solution:
>> http://wordpress.org/support/topic/bug-add_post_meta-update_post_meta
>>
>> Basically, the unenscaped data will be not saved.
>>
>> *Doesn't: *add_post_meta($post_id, 'json-data', $json_string);
>>
>> *Works: *add_post_meta($post_id, 'json-data',
>> $wpdb->escape($json_string));
>>
>>
>> Lea and I have the following questions:* Is this a bug or a feature?
>> *
>> Kindly,
>>
>> Baki Goxhaj
>> www.wplancer.com | www.banago.info | proverbhunter.com
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>>
>
> --
> Dion Hulse / dd32
> Contact:
> e: contact at dd32.id.au
> Web: http://dd32.id.au/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list