Hi All
In some circumstances (e.g. when using simplenews and mimemail) the _drupal_html_to_text_pad helper function called by drupal_html_to_text can try to pad headers with negative padding.
This can happen when using nodereferences to pull teasers into a newsletter.
For example:
print drupal_html_to_text('<h2>This is an extremely long title for a node http://www.example.com/news/this-is-an-extremely-long-title-for-a-node </h2>');
This patch stops the padding length from falling below zero.
Cheers
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | mail.inc_.padding-508738-6.patch | 732 bytes | eric_a |
| mail.inc_.padding.patch | 537 bytes | terrychild |
Comments
Comment #1
RAguilar commentedwhat about something like this
line:480
$value = (($n - strlen($prefix))>=0)? ($n - strlen($prefix)) : 0;
return $text . $prefix . str_repeat($pad, $value) ."\n";
this prevents from falling below zero but i dont know if this is the best solution
Comment #2
paulrooney commentedThis patch worked great and resolved PHP errors when sending HTML mail with Mime Mail 6.x-1.0-alpha1 and Simplenews 6.x-1.0-rc6
The error message was as follows:
str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in /home/[username]/drupal-6.14/includes/mail.inc on line 480.
Thanks!
Comment #3
Delta Bridges commentedI am having a similar error when sending newsletter with mime mail and simplenews:
str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in /home/xxx/public_html/xxx/includes/mail.inc on line 480.
Will this patch be implemented in a future version?
Many thanks
Comment #4
eric_a commentedIf the issue is with _drupal_html_to_text_pad() then move to 7.x to increase chances on getting some attention. The only difference between 7.x version and 6.x is coding style.
Comment #6
eric_a commentedReroll.
Comment #7
eric_a commentedThis bug blocks a decent test #299138: Improve \Drupal\Core\Utility\Mail::htmlToText() and gives us PHP warnings
and messed up e-mail bodies.Comment #8
catchBlocking a test doesn't qualify this as a release blocker.
Comment #9
eric_a commentedWith the patch we are always lowering the repeat multiplyer, i.e. changing the behaviour even for the cases that did not produce an error. The suggestion from Raguilar in #1 only changes the multiplier if it would fall below zero, which is in line with the goal of this issue.
Comment #10
eric_a commentedOMG, I can't believe I said that (#9). It is totally wrong.
Raguilar had the same idea and basically the same code as terrychild and the code seems fine to me, too.
Comment #11
dries commentedCommitted to CVS HEAD. Moving to Drupal 6.
Comment #12
eric_a commentedPatch in OP
#1still applies perfectly to DRUPAL-6.Comment #13
gábor hojtsyThanks, committed.