[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail:[14961] trunk/squirrelmail/functions/mime.php
From: pdontthink--- via squirrelmail-cvs <squirrelmail-cvs () lists ! sourceforge ! net>
Date: 2022-05-23 0:25:07
Message-ID: 1653265507.563167.13204 () sfp-scm-1 ! v30 ! lw ! sourceforge ! com
[Download RAW message or body]
Revision: 14961
http://sourceforge.net/p/squirrelmail/code/14961
Author: pdontthink
Date: 2022-05-23 00:25:07 +0000 (Mon, 23 May 2022)
Log Message:
-----------
Greatly fix the plaintext display of messages that do not have a text part. Patch \
from Alexey Shpakovsky (#496)
Modified Paths:
--------------
trunk/squirrelmail/functions/mime.php
Modified: trunk/squirrelmail/functions/mime.php
===================================================================
--- trunk/squirrelmail/functions/mime.php 2022-05-23 00:19:51 UTC (rev 14960)
+++ trunk/squirrelmail/functions/mime.php 2022-05-23 00:25:07 UTC (rev 14961)
@@ -396,18 +396,38 @@
*/
if ($body_message->header->type1 == 'html') {
- if ($show_html_default <> 1) {
+ // Do we need to make an HTML part viewable as non-HTML plain text?
+ if ($show_html_default != 1) {
$entity_conv = array(' ' => ' ',
- '<p>' => "\n",
- '<P>' => "\n",
- '<br>' => "\n",
- '<BR>' => "\n",
- '<br />' => "\n",
- '<BR />' => "\n",
+ // These are better done by regex (below)
+ // '<p>' => "\n",
+ // '<P>' => "\n",
+ // '<br>' => "\n",
+ // '<BR>' => "\n",
+ // '<br />' => "\n",
+ // '<BR />' => "\n",
+ // '<tr>' => "\n",
+ // '<div>' => "\n",
'>' => '>',
- '<' => '<');
+ '<' => '<',
+ '&' => '&',
+ '©' => ' ©');
+ // first, completely remove <style> tags as they aren't useful in \
this context + $body = preg_replace('/<style.*>.*<\/style.*>/isU', '', \
$body); + // emulate how newlines are treated as spaces in HTML
+ $body = preg_replace('/(\r|\n)+/', ' ', $body);
+ // now replace the tags listed just above
$body = strtr($body, $entity_conv);
+ // <p>, <br>, <tr> and <div> are best replaced by a newline
+ $body = preg_replace('/<(p|br|tr|div).*>/isU', "\n", $body);
+ // remove the rest of the HTML tags
$body = strip_tags($body);
+ // condense multiple spaces into one
+ $body = preg_replace('/[ \t]+/', ' ', $body);
+ // trim each line
+ $body = preg_replace('/ *\n */', "\n", $body);
+ // allow maximum two newlines
+ $body = preg_replace('/\n\n\n+/', "\n\n", $body);
$body = trim($body);
translateText($body, $wrap_at,
$body_message->header->getParameter('charset'));
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic