From 6dd449551eabda8cff0b2f4a747f564ec83aa9d3 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 06:16:34 +0000 Subject: [PATCH] Eliminate the use of `extract()` in `wp_mail()`. Check the filtered array for each value before re-setting variables. See #22400. git-svn-id: https://develop.svn.wordpress.org/trunk@28425 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index d5a680737b..c51e5b6d2d 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -233,11 +233,31 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() * @param array $args A compacted array of wp_mail() arguments, including the "to" email, * subject, message, headers, and attachments values. */ - extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); + $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); - if ( !is_array($attachments) ) + if ( isset( $atts['to'] ) ) { + $to = $atts['to']; + } + + if ( isset( $atts['subject'] ) ) { + $subject = $atts['subject']; + } + + if ( isset( $atts['message'] ) ) { + $message = $atts['message']; + } + + if ( isset( $atts['headers'] ) ) { + $headers = $atts['headers']; + } + + if ( isset( $atts['attachments'] ) ) { + $attachments = $atts['attachments']; + } + + if ( ! is_array( $attachments ) ) { $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) ); - + } global $phpmailer; // (Re)create it, if it's gone missing