Maillist.php patch for pure html mails [message #159246] |
Fri, 15 May 2009 08:26 |
Peter Vendike
Messages: 65 Registered: February 2009 Location: Denmark
Karma: 0
|
Member Translator |
|
|
In (rare) cases where the imported mail has no 'text/plain' alternative and is pure html, the body-text showed up as one long line, barely readable (of cause only if 'Allow HTML in Mailing List Messages' is off).
This small patch saves the line breaks and the text formatting is kept for the imported message.
*** maillist.php 2009-05-14 17:39:33.000000000 +0200
--- maillist_pat.php 2009-05-15 09:44:54.000000000 +0200
***************
*** 121,126 ****
--- 121,129 ----
case 'text/html':
$this->decode_message_body();
+ // We need to keep line breaks for textformatting befor using 'strip_tags'
+ $l_breaks = array("<br />", "</p>", "<p>", "<br>" );
+ $this->body = str_replace($l_breaks, "\n", $this->body);
$this->body = (!$html ? strip_tags($this->body) : $this->body);
break;
[Updated on: Fri, 15 May 2009 08:55] Report message to a moderator
|
|
|
Re: Maillist.php patch for pure html mails [message #159247 is a reply to message #159246] |
Fri, 15 May 2009 10:21 |
|
naudefj
Messages: 3771 Registered: December 2004
Karma: 28
|
Senior Member Administrator Core Developer |
|
|
Will this also work:
Index: maillist.php
===================================================================
RCS file: /forum21/install/forum_data/scripts/maillist.php,v
retrieving revision 1.78
diff -u -r1.78 maillist.php
--- maillist.php 3 May 2009 18:43:45 -0000 1.78
+++ maillist.php 15 May 2009 10:20:02 -0000
@@ -121,7 +121,11 @@
case 'text/html':
$this->decode_message_body();
- $this->body = (!$html ? strip_tags($this->body) : $this->body);
+ if (!$html) {
+ $this->body = str_ireplace(array('<br />', '<br>'), "\n", $this->body);
+ $this->body = str_ireplace(array('<p>', '</p>'), "\n\n", $this->body);
+ $this->body = strip_tags($this->body);
+ }
break;
case 'multipart/parallel': // Apparently same as multipart/mixed but order of body parts does not matter
|
|
|
|
Re: Maillist.php patch for pure html mails [message #159253 is a reply to message #159251] |
Sat, 16 May 2009 13:02 |
Peter Vendike
Messages: 65 Registered: February 2009 Location: Denmark
Karma: 0
|
Member Translator |
|
|
Hej Frank
I tried your patch today, the "\n\n" for "<p>" looks more like the original html, so i think we could use your model, still keeping only 1 "\n" for "</p>" , and i also don't believe its necessary to ask for html=true ones again.
Peter
$this->decode_message_body();
$this->body = str_replace("<p>", "\n\n", $this->body);
$this->body = str_replace(array("<br />", "</p>", "<br>" ), "\n", $this->body);
$this->body = strip_tags($this->body);
break;
[Updated on: Sat, 16 May 2009 13:05] Report message to a moderator
|
|
|
|
Re: Maillist.php patch for pure html mails [message #159255 is a reply to message #159254] |
Sat, 16 May 2009 14:01 |
Peter Vendike
Messages: 65 Registered: February 2009 Location: Denmark
Karma: 0
|
Member Translator |
|
|
Yes I was just thinking the same, if that is used for the multipart bodies? I just can't deduct that.
Just to say, it work for some multipart test messages without that test:
$this->body = (!$html ? strip_tags($this->body) : $this->body);
else one could do something like $html => break earlier?
also, i don't now if these tags are sometimes used in capitals, so we need the case-insensitive version?
Peter
[Updated on: Sat, 16 May 2009 14:35] Report message to a moderator
|
|
|
|
|
|