• Resolved carryoncoding

    (@carryoncoding)


    Hi,
    My notification emails have become corrupted pretty much just as the new plugin update (1.9) was installed.

    Originally, the header of the email was setup like this:

    <!DOCTYPE html>
    <html lang="en" xmlns="https://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width,initial-scale=1">
            <meta name="x-apple-disable-message-reformatting">
            <title></title>
            <!--[if mso]>
                <noscript>
                    <xml>
                    <o:OfficeDocumentSettings>
                    <o:PixelsPerInch>96</o:PixelsPerInch>
                    </o:OfficeDocumentSettings>
                    </xml>
                </noscript>
            <![endif]-->
            <style>
                .email-button {
    

    But after the update, the notification message body is full of blank lines and looks like this:

        
            
            
            
            <title></title>
            <!--[if mso]>-->
                
                    
                    
                    96
                    
                    
                
            
            
                .email-button {
    

    I tried pasting the code back into the message body box, saved it, tried a test, and the code was deleted again.
    Please can you help?
    Thanks,
    Phil.

Viewing 10 replies - 16 through 25 (of 25 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @carryoncoding,
    I have a fix in place but it’s not ready as part of a larger release at the moment.

    For now, if you’re happy modifying the plugin, you should be able to change the line in /wp-plugins/bnfw/includes/admin/class-bnfw-notification.php that reads:

    'message' => isset( $_POST['notification_message'] ) ? wp_kses_post( wp_unslash( $_POST['notification_message'] ) ) : '',

    to:

    'message' => isset( $_POST['notification_message'] ) ? $this->bnfw_kses_message_field( wp_unslash( $_POST['notification_message'] ) ) : '',

    then add this to the bottom of that file:

    /**
    * Filters out the same tags as wp_kses_post, but allows some extra tags.
    *
    * @since 1.10
    *
    * @param string $message Content to filter through kses.
    *
    * @return string
    */
    public function bnfw_kses_message_field( $message ) {
    $allowed_tags = array_replace_recursive(
    
    wp_kses_allowed_html( 'post' ),
    array(
    'html' => array(
    'lang' => true,
    'xmlns' => true,
    ),
    'meta' => array(
    'name' => true,
    'charset' => true,
    'content' => true,
    ),
    'style' => true,
    'head' => true,
    'body' => array(
    'style' => true,
    ),
    )
    );
    
    /**
    * Kses message allowed tags.
    *
    * @since 1.10
    *
    * @param array[]|string $allowed_tags An array of allowed HTML elements and attributes, or a context name such as 'post'.
    */
    return wp_kses( $message, apply_filters( 'bnfw_kses_message_allowed_tags', $allowed_tags ) );
    }

    Let me know how you get on with this.

    Thread Starter carryoncoding

    (@carryoncoding)

    Thanks for sharing that code. I added as you described. Then pasted my html (shared 7 Sep 2022) into the “Message body” window.

    When I clicked “Save”, the code was immediately corrupted as per the images I sent on 7 Sep. No change.

    Perhaps something else is at play?

    Kind regards,

    Phil.

    Plugin Author bnfw

    (@voltronik)

    Hi @carryoncoding,

    Are you able to clear your transients and your cache (if using one) and then re-test?

    Thread Starter carryoncoding

    (@carryoncoding)

    Thanks. Cleared transients, cleared browser cache. No other cache used on the site. Pasted in the html and the same result.

    Plugin Author bnfw

    (@voltronik)

    Hi @carryoncoding,
    Ok, thanks.

    Can you confirm that some of the tags mentioned in the code snippet I posted above are now working in your notification?

    Thread Starter carryoncoding

    (@carryoncoding)

    Interesting progress. The original issue remains. The html pasted into “Message body” window is corrupted as soon as you hit “Save”.

    However, the email that results now looks different. Before I modified /wp-plugins/bnfw/includes/admin/class-bnfw-notification.php, the email reproduced a lot of the css at the top. Now, the only indication of a problem in the email is the number “96” appearing at the top, before the first bit of content.

    Plugin Author bnfw

    (@voltronik)

    Hi @carryoncoding,
    That’s good that it’s working, even if not quite right.

    If you do this does it work as expected? I suspect the 96 might be part of a tag that isn’t allowed.

    Thread Starter carryoncoding

    (@carryoncoding)

    Sorry for delay. I have now set this up and will test for a few days. I’ll report back at that point.

    Cheers,

    Phil.

    Thread Starter carryoncoding

    (@carryoncoding)

    That’s now working fine! I don’t follow how to add an image to this post, but the generated email is all looking good.

    Thanks for your help.

    Phil.

    Plugin Author bnfw

    (@voltronik)

    Hi @carryoncoding,
    That’s great! So please you have it working now and thank you for your persistence.
    The next version of BNFW (delayed at present) will have this code included.

    If you like BNFW and the support, please feel free to leave an honest review.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Corrupted emails’ is closed to new replies.