I'm sending rendered table through mail using Mimemail module.
And this table is totally broken, because of hardcoded limit of line width set to 77 chars in _drupal_wrap_mail_line()
Example
This code:
$line = <ul class="links inline"><li class="comment_forbidden first last"></li>
breaking the line to:
$line = "<ul class="links inline"><li\n
class="comment_forbidden first last"></li>"
Then when filter is activated, function _filter_autop() making another line breaking ("in an intelligent fashion"):
$chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
this time line looks like:
$line = "<ul class="links inline"><li<br/> class="comment_forbidden first last"></li>"
All this causing unexpected output in mail:
class="comment_forbidden first last">
Comments
Comment #1
kenorb commentedTemporary core patch for my own purpose until proper fix.
Comment #2
damien tournoud commented_drupal_wrap_mail_line() is designed to run last (just before the mail is sent). Running filters after the mail has been wrapped sounds like a bug in the Mimemail module.
Comment #3
kenorb commentedI'm not sure if this module solve that issue:
http://drupal.org/project/smartlinebreakconverter
Comment #4
damien tournoud commentedProbably not a core bug.
Comment #5
kenorb commentedThanks for reply.
I'll make some additional tests.
Comment #6
kenorb commentedSorry, post in the same time revert your changes;)
Comment #7
kenorb commentedThere could be some conflict if I'm sending rendered node via node_view($node, FALSE, TRUE) through mail?
Some unexpected double calls, rendering, then _drupal_wrap_mail_line could be not run last, arguments which I can't use in this case, or something?
Basically it's my custom defined token (Token) like [my-node], which contain rendered node node_view($node, FALSE, TRUE) which is sent through mail using Actions (Send tokenized e-mail).
Comment #8
kenorb commentedTest 1 by sending Newsletter with following content (using Mimemail):
was received properly (where 246 is nid of some node).
OK
Test 2 by sending Newsletter with following token (using Mimemail):
was received properly.
OK
Test 3
Assigned Tokenized Mail action with '[my-node]' rendered through node_view() on content update.
Mail is broken.
NOT OK
Comment #9
kenorb commentedDisabling 'Line break converter' from Full HTML fix the problem with broken HTML.
So I think it's rather Filter issue, than Mimemail.
There are already too many issues with Filter, so one more will not make any difference.
Comment #10
kenorb commentedComment #11
damien tournoud commentedThis has nothing to do with the filter system. As I told you already, drupal_wrap_mail() is supposed to be called *after* all filtering has taken place. Please try to find out why it is not the case in your particular use case.
Requalifying as a support request until you have more information.
Comment #12
damien tournoud commentedHere is the probable code flow. The mail first get prepared by:
- token_actions_send_email_action()
- drupal_html_to_text()
- drupal_wrap_mail()
- drupal_mail()
- drupal_mail_wrapper()
Then Mime mail does:
- $body = check_markup($body, ...), running the line break converter on an already wrapped mail
Sure, the line break converter could be a lot better... but I have no idea why Mime mail wants to run check_markup() there.
Comment #13
mdupontMime Mail issue it is, then.
Comment #14
sgabe commentedI am marking this as a duplicate of #1128354: Check markup only before wrapping, since there is a patch that addresses this bug, although we need to remove the check_markup() call from drupal_mail_wrapper() too. Please, post any further comments there.