Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode HTML entities in email subject. #6

Open
wants to merge 1 commit into
base: 7.x-2.x
Choose a base branch
from

Conversation

RoSk0
Copy link

@RoSk0 RoSk0 commented Oct 13, 2015

Fix for the subject issue as well as small code style improvements.

Drupal.org issue page https://www.drupal.org/node/2386273.

@amitaibu
Copy link
Member

I see in the original issue:

In building the subject line, the MessageNotifierEmail class strips tags from the text but it fails to decode HTML entities. So a subject line which should be 'New post on the topic "some title"' actually comes out as 'New post on the topic "some title"'.

I can't see the difference in that above example ;) Also, it would be great if it had a simpleTest -- can you write one?

@RoSk0
Copy link
Author

RoSk0 commented Oct 13, 2015

Fixed issue description.
I'm not really experienced with SimpleTest so I have failed to write a test, but what I have came up with is this:

  $test_str = "Sting ' with " . 'quotes " and HTML entities &.';
  $msg_type = 'test_email';
  $message_type_obj = message_type_create($msg_type);
  $wrapper = entity_metadata_wrapper('message_type', $message_type_obj);
  $wrapper->{MESSAGE_FIELD_MESSAGE_TEXT}[] = array('value' => $test_str, 'format' => 'plain_text');
  $wrapper->save();

  $message = message_create($msg_type);
  message_notify_send_message($message, array('mail' => '[email protected]'));
  $output = $message->output;

  $this->assertEqual($output['message_notify_email_subject'], $test_str, 'Entities has been successfully decoded in email subject.');

But my issue here is that I must test a real MessageNotifierEmail class and I'm not sure how exactly I should do this:

  1. We do not want it to sent out an emails.
  2. We want it to behave exactly like MessageNotifierTest::deliver in terms of storing prepared output in $message object and returning status set on $message.

I want to get familiar with this so any help would be appreciated!

@RoSk0
Copy link
Author

RoSk0 commented Oct 13, 2015

Just to be explicit: without this PR with the subject set to >Sting ' with quotes " and HTML entities &.< you will end up receiving email with subject >Sting &#39; with quotes &quot; and HTML entities &amp;.<

@amitaibu
Copy link
Member

@ordavidil can you give a shot at the tests please :)

@ordavidil
Copy link

@amitaibu
Sure, I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants