Escape properly the metadata to be copied.

Fixes a SQL injection because the meta key can contain arbitrary values.
This commit is contained in:
Alexander Concha 2015-05-19 10:37:14 +02:00 committed by Mike Jolley
parent 3c1b14d00d
commit f38bc86c5d
1 changed files with 1 additions and 3 deletions

View File

@ -247,9 +247,7 @@ class WC_Admin_Duplicate_Product {
$sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
foreach ( $post_meta_infos as $meta_info ) {
$meta_key = $meta_info->meta_key;
$meta_value = addslashes( $meta_info->meta_value );
$sql_query_sel[]= "SELECT $new_id, '$meta_key', '$meta_value'";
$sql_query_sel[]= $wpdb->prepare( "SELECT %d, %s, %s", $new_id, $meta_info->meta_key, $meta_info->meta_value );
}
$sql_query.= implode( " UNION ALL ", $sql_query_sel );