The helper function _drupal_html_to_mail_urls() accumulates the URLs that drupal_html_to_text() encounters, so that it can return a list of them to put at the bottom of the email. If you want to run drupal_html_to_text() more than once (for example the Subscriptions module sending out a bunch of emails in one cron run), then the list of URLs just keeps accumulating.
drupal_html_to_text() needs to reset _drupal_html_to_mail_urls() at the end, and the first attached patch does that. It does not change the behavior of either function. IMO this needs to make it into D6, because drupal_html_to_text() is broken.
If the same URL occurs more than once in a text, then the list has duplicates. It would be nice, if these could be omitted. The second patch does that in addition to adding the reset mechanism and would be nice to have.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | reset_mail_urls.patch | 1.83 KB | gábor hojtsy |
| #1 | drupal_html_to_text.more_than_once.patch | 891 bytes | salvis |
| #1 | drupal_html_to_text.more_than_once.remove_duplicates.patch | 1.11 KB | salvis |
Comments
Comment #1
salvisHmm, lost my attachments...
Comment #2
chx commentedIf D6 can't send more than HTML mail per page that's imo a critical problem
Comment #3
gábor hojtsyWhy not add a $reset parameter? It would be much cleaner, and compared to that it is a minor API modification to solve a critical omission. (I would not expand logic to collect the fold the same URL, so let's keep focusing on adding a clean reset option).
In fact, it looks like _drupal_html_to_mail_urls() needs a $reset parameter and it needs to be reset before the call to
preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);Comment #4
cburschkaQuick note: The diff "-p" option (as far as I know) adds the relevant function name to each chunk. That makes it a lot easier to see what function is being changed and what their parameters are; I can only guess that the first one is html_to_text and the second one is the urls function.
Comment #5
gábor hojtsyHere is the approach I suggested, please review/test.
Comment #6
gábor hojtsyA simple script to test before and after the patch:
Comment #7
webchickOk, confirmed the problem without the patch, applied the patch and did a few variation of the script. Things worked. :) RTBC.
Comment #8
gábor hojtsyThanks, committed.
Comment #9
salvisThanks. I had a (pre-announced) power outage here that kept me from pursuing this in a timely manner.
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.