Make WordPress Core

Ticket #9913: 9913.diff

File 9913.diff, 1.4 KB (added by Speedboxer, 16 years ago)

Ensure plain text emails aren't sent with encoded quotes

  • wp-includes/pluggable.php

     
    249249 * @param string $message Message contents
    250250 * @param string|array $headers Optional. Additional headers.
    251251 * @param string|array $attachments Optional. Files to attach.
     252 * @param bool $preserve_quotes Optional. Preserve encoded quotes in plain text emails.
    252253 * @return bool Whether the email contents were sent successfully.
    253254 */
    254 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
     255function wp_mail( $to, $subject, $message, $headers = '', $attachments = array(), $preserve_quotes = false ) {
    255256        // Compact the input, apply the filters, and extract them back out
    256257        extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
    257258
     
    337338                }
    338339        }
    339340
     341        if ( $preserve_quotes != true && ( !isset( $content_type ) || $content_type = 'text/plain' ) ) {
     342                // Ensure we don't send encoded quotes in plain text emails
     343                $encoded_quotes = array( '"', ''' );
     344                $decoded_quotes = array( '"', "'" );
     345                $subject = str_replace( $encoded_quotes, $decoded_quotes, $subject );
     346                $message = str_replace( $encoded_quotes, $decoded_quotes, $message );
     347        }
     348
    340349        // Empty out the values that may be set
    341350        $phpmailer->ClearAddresses();
    342351        $phpmailer->ClearAllRecipients();