Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/14/2016 04:52:11 PM (8 years ago)
Author:
r-a-y
Message:

Emails: Ensure that the email subject is HTML entity-decoded.

Fixes an issue when using email tokens that contain HTML special characters
in the email subject.

Fixes #6966 (2.5-branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/tests/phpunit/testcases/core/class-bp-email.php

    r10541 r10760  
    251251        $this->assertSame( $new_recipient, $addresses[1]->get_address() );
    252252    }
     253
     254    public function test_html_entities_are_decoded_in_email_subject() {
     255        // Emulate custom post title for an email post type.
     256        $subject = "It's pretty <new & magical.";
     257
     258        $email = new BP_Email( 'activity-at-message' );
     259        $email->set_subject( $subject )->set_tokens( array( 'poster.name' => 'blah' ) );
     260
     261        // Subject always has to have tokens replaced before sending.
     262        $this->assertSame( $subject, $email->get_subject( 'replace-tokens' ) );
     263    }
     264
     265    public function test_html_entities_are_decoded_in_email_recipient_names() {
     266        // Raw display name.
     267        $name = "Test o'Toole";
     268
     269        // Emulate rendered {poster.name} token.
     270        $token = apply_filters( 'bp_core_get_user_displayname', $name );
     271
     272        $email = new BP_Email( 'activity-at-message' );
     273        $email->set_subject( '{{poster.name}}' )->set_tokens( array( 'poster.name' => $token ) );
     274
     275        // Subject always has to have tokens replaced before sending.
     276        $this->assertSame( $name, $email->get_subject( 'replace-tokens' ) );
     277    }
     278
    253279}
Note: See TracChangeset for help on using the changeset viewer.