#6966 closed defect (bug) (fixed)
Email Subject special characters display problem with initiator.name token (BuddyPress v2.5.1)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5.3 | Priority: | high |
Severity: | normal | Version: | 2.5.0 |
Component: | Emails | Keywords: | has-patch commit |
Cc: |
Description
Original post to Support https://buddypress.org/support/topic/special-characters-in-initiator-name-token/
Running into a problem with special characters in the initiator.name email token. If the name has a special character like an apostrophe (e.g. O'Neil) that token displays fine in the email message body. On the message's Subject though it appears as...
[RGP] New friendship request from Tom O'Neil
Had a recommendation to try a filter using stripslashes() such as this...
apply_filters( 'bp_email_set_subject', $subject, $this ); function RGP_email_subject( $subject, $obj ) { $subject = stripslashes( $subject ); return $subject; } add_filter( 'bp_email_set_subject', 'RGP_email_subject', 15, 2 );
I used that specifically but it did not affect the Subject text.
I tried a different version of that below. I was able to get the extra string of text appended to $subject, but couldn't get either version of the str_replace() to change the problem text...
apply_filters( 'bp_email_set_subject', $subject, $this ); function RGP_email_subject( $subject, $obj ) { $subject = stripslashes( $subject ); //tried this 1st //$subject = str_replace( ''', "'", $subject ); //tried this 2nd //$subject = addslashes( str_replace( ''', "'", $subject ) ); //tried this 3rd $subject = str_replace( ''', "TEST", $subject ); $subject .= " append custom text"; return $subject; } add_filter( 'bp_email_set_subject', 'RGP_email_subject', 15, 2 );
Attachments (2)
Change History (19)
#3
@
9 years ago
And probably do the same for the "From Name", "To Names", "BCC Names", "CC Names".
We already do this for the default value of "From Name", but we should make sure it's always done.
This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.
9 years ago
This ticket was mentioned in Slack in #buddypress by dcavins. View the logs.
9 years ago
#11
@
9 years ago
@r-a-y mentioned this ticket in the dev meeting today. I've added a patch of tests I was trying to write to prove the problem, but I was struggling to do that. I couldn't get the right kind of character entity in my test.
#12
@
9 years ago
- Keywords has-patch added; needs-patch removed
@DJPaul - I've attached a patch for the email subject decoding issue.
What we were lacking was HTML decoding when fetching the email subject. I'm also switching when we use html_entity_decode()
; we should only do this when $transform
is set to replace-tokens
.
I've also modified the unit tests. The first test in tests-in-progress.diff
uses wptexturize()
, which will not be used; when we fetch the email post, post title is always raw. Second test has been simplified.
Let me know what you think.
#14
@
9 years ago
Can we get this tested by someone please and committed? It's blocking 2.5.3 which has more important email fixes in.
For this, we need to filter the
get_subject()
withwp_specialchars_decode( $the_value, ENT_QUOTES )
which should do it.