I just realized there is no email system so I put this on the base. Rfay found an issue in the email system and we are not sure if this is a bug in the email system or intended behavior. When sending a plain text message including the '<' character, the body is truncated at this character by the drupal_html_to_text() function, even if the body is not html.
I'm writing the issue from my poor understanding of the email system, so I'll ask some questions I can't reply myself.
1st - The format() method of the DefaultMailSystem class (modules/system/mail.sending.inc) forces the conversion of the message body from html to text. Should this happen for plain text emails also?
2nd - the function drupal_html_to_text() should remove a bogus html tag when it is not closed?
These two concerns combined break the tests of the email_example module when trying to send a message with the character '<' followed by arbitrary characters of well known html tags in a random body.
Basically what is happening is that the following call on plain text body:
drupal_html_to_text(" this simple check, if(a<b) should fail");
returns the string "this simple check, if(a*"
Comments
Comment #1
rfayGood detective work - thanks for tracking this down, ilo.
This seems like a fundamental "wrong" with emails, since it inexplicably would throw away the remainder of an email body where the user used the
<character for any reason.Comment #2
sunAll e-mail messages are now considered to be HTML.
Plain-text messages should follow this flow:
Comment #3
ilo commentedThanks sun for your attention.
In an attempt to document this 'requirement' (for the D6 to D7 upgrade handbook, and the email example module) I can't find any issue about that, so don't know where to point about that.
Is this string " < b " (without spaces) considered an invalid html tag? or the function drupal_html_to_text is not working as expected with tags not closed properly?
Edited: the " < b " string just truncated the next sentence in the comment (I thought it was only happening in the email system..). It is a copy of the previous one but removing the spaces between < and b.
On the other hand.. is the "
Comment #4
rfay@ilo, there's great irony that your post was truncated with the introduction of a
<. You probably have to return and finish it :-)Comment #5
ilo commented@rfay, I edited, and posted the line with a fix and without it to be kept as demonstration :)
Comment #6
rfay@sun (#2) So you're saying this is a behavior change for D7? I don't see anything on the module update page about this, but I'll be happy to add it. Is the basic information you put in #2 adequate for this, or is there a broader context?
Comment #7
rfayI'll document this per sun's statement in #2. @sun, are there any other email changes in behavior that go with this? Can you point me to an issue where it was discussed?
Comment #8
rfaySun beat me to this in http://drupal.org/node/727352. I added a little bit to it. @sun you may want to review.
Followup on the Email Example at #730984: Email example (D7) needs to check_plain on user text