Use wp_slash() instead of the DB layer in XML-RPC. see #21767.
git-svn-id: http://core.svn.wordpress.org/trunk@24716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ab72605607
commit
69dbdc4951
|
@ -211,28 +211,20 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitize string or array of strings for database.
|
* Escape string or array of strings for database.
|
||||||
*
|
*
|
||||||
* @since 1.5.2
|
* @since 1.5.2
|
||||||
*
|
*
|
||||||
* @param string|array $array Sanitize single string or array of strings.
|
* @param string|array $data Escape single string or array of strings.
|
||||||
* @return string|array Type matches $array and sanitized for the database.
|
* @return string|array Type matches $data and sanitized for the database.
|
||||||
*/
|
*/
|
||||||
function escape(&$array) {
|
function escape( &$data ) {
|
||||||
global $wpdb;
|
if ( ! is_array( $data ) )
|
||||||
|
return wp_slash( $data );
|
||||||
|
|
||||||
if (!is_array($array)) {
|
foreach ( $data as &$v ) {
|
||||||
return($wpdb->escape($array));
|
if ( ! is_object( $v ) )
|
||||||
} else {
|
$v = wp_slash( $v );
|
||||||
foreach ( (array) $array as $k => $v ) {
|
|
||||||
if ( is_array($v) ) {
|
|
||||||
$this->escape($array[$k]);
|
|
||||||
} else if ( is_object($v) ) {
|
|
||||||
//skip
|
|
||||||
} else {
|
|
||||||
$array[$k] = $wpdb->escape($v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2985,9 +2977,9 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$comment['comment_post_ID'] = $post_id;
|
$comment['comment_post_ID'] = $post_id;
|
||||||
|
|
||||||
if ( $logged_in ) {
|
if ( $logged_in ) {
|
||||||
$comment['comment_author'] = $wpdb->escape( $user->display_name );
|
$comment['comment_author'] = $this->escape( $user->display_name );
|
||||||
$comment['comment_author_email'] = $wpdb->escape( $user->user_email );
|
$comment['comment_author_email'] = $this->escape( $user->user_email );
|
||||||
$comment['comment_author_url'] = $wpdb->escape( $user->user_url );
|
$comment['comment_author_url'] = $this->escape( $user->user_url );
|
||||||
$comment['user_ID'] = $user->ID;
|
$comment['user_ID'] = $user->ID;
|
||||||
} else {
|
} else {
|
||||||
$comment['comment_author'] = '';
|
$comment['comment_author'] = '';
|
||||||
|
@ -4923,8 +4915,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$blog_ID = (int) $args[0];
|
$blog_ID = (int) $args[0];
|
||||||
$username = $wpdb->escape($args[1]);
|
$username = $this->escape($args[1]);
|
||||||
$password = $wpdb->escape($args[2]);
|
$password = $this->escape($args[2]);
|
||||||
$data = $args[3];
|
$data = $args[3];
|
||||||
|
|
||||||
$name = sanitize_file_name( $data['name'] );
|
$name = sanitize_file_name( $data['name'] );
|
||||||
|
@ -5451,7 +5443,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
|
$pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
|
||||||
|
|
||||||
$context = '[…] ' . esc_html( $excerpt ) . ' […]';
|
$context = '[…] ' . esc_html( $excerpt ) . ' […]';
|
||||||
$pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
|
$pagelinkedfrom = $this->escape( $pagelinkedfrom );
|
||||||
|
|
||||||
$comment_post_ID = (int) $post_ID;
|
$comment_post_ID = (int) $post_ID;
|
||||||
$comment_author = $title;
|
$comment_author = $title;
|
||||||
|
|
Loading…
Reference in New Issue