Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/14/2016 04:54:40 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.

See #6966 (trunk)

File:
1 edited

Legend:

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

    r10669 r10761  
    268268        $this->assertTrue( $result );
    269269    }
     270
     271    public function test_html_entities_are_decoded_in_email_subject() {
     272        // Emulate custom post title for an email post type.
     273        $subject = "It's pretty <new & magical.";
     274
     275        $email = new BP_Email( 'activity-at-message' );
     276        $email->set_subject( $subject )->set_tokens( array( 'poster.name' => 'blah' ) );
     277
     278        // Subject always has to have tokens replaced before sending.
     279        $this->assertSame( $subject, $email->get_subject( 'replace-tokens' ) );
     280    }
     281
     282    public function test_html_entities_are_decoded_in_email_recipient_names() {
     283        // Raw display name.
     284        $name = "Test o'Toole";
     285
     286        // Emulate rendered {poster.name} token.
     287        $token = apply_filters( 'bp_core_get_user_displayname', $name );
     288
     289        $email = new BP_Email( 'activity-at-message' );
     290        $email->set_subject( '{{poster.name}}' )->set_tokens( array( 'poster.name' => $token ) );
     291
     292        // Subject always has to have tokens replaced before sending.
     293        $this->assertSame( $name, $email->get_subject( 'replace-tokens' ) );
     294    }
     295
    270296}
Note: See TracChangeset for help on using the changeset viewer.