* Events:
- #517: URL catcher update (www). -Car
+ * Lists:
+ - #485: Can moderate pure-HTML mails -FRU
+
* Profile:
- #451: vCard are RFC compliant -FRU
- #502: Use 'alias' instead of 'aka' to specify the nickname -FRU
if raw:
return str(msg)
- results = []
+ results_plain = []
+ results_html = []
for part in typed_subpart_iterator(msg, 'text', 'plain'):
c = part.get_payload()
- if c is not None: results.append (c)
- results = map(lambda x: quote(x), results)
+ if c is not None: results_plain.append (c)
+ results_plain = map(lambda x: quote(x), results_plain)
+ for part in typed_subpart_iterator(msg, 'text', 'html'):
+ c = part.get_payload()
+ if c is not None: results_html.append (c)
+ results_html = map(lambda x: quote(x), results_html)
return {'id' : id,
'sender': quote(sender, True),
'size' : size,
'subj' : quote(subject, True),
'stamp' : ptime,
- 'parts' : results }
+ 'parts_plain' : results_plain,
+ 'parts_html': results_html }
except:
mlist.Unlock()
return 0
return $globals->mail->domain;
}
+ function clean_html($res)
+ {
+ $res = html_entity_decode($res);
+ $res = preg_replace('@<a[^>]*href=["\']([^ >]+)["\'][^>]*>([^<]*)</a>@i', "\\2 [\\1]", $res);
+ $res = preg_replace("@<(/br|p|/div)[^>]*>(\\s*\n)?@i", "\n", $res);
+ $res = trim(strip_tags($res));
+ $res = preg_replace("/\n(\\s*\n)+/", "\n\n", $res);
+ return htmlentities($res);
+ }
+
function handler_lists(&$page)
{
$this->prepare_client($page);
$page->register_modifier('qpd', 'quoted_printable_decode');
$page->register_modifier('hdc', 'list_header_decode');
+ $page->register_modifier('clean_html', array($this, 'clean_html'));
if (Env::has('sadd')) { /* 4 = SUBSCRIBE */
$this->client->handle_request($liste,Env::v('sadd'),4,'');
Contenu du mail en attente
</h1>
-{if $mail.parts|@count}
+{if $mail.parts_plain|@count}
<table class='bicol' cellpadding='0' cellspacing='0'>
- {foreach from=$mail.parts item=part key=i}
+ {foreach from=$mail.parts_plain item=part key=i}
<tr><th>Partie n°{$i}</th></tr>
<tr class='{cycle values="impair,pair"}'>
<td><tt>{$part|qpd|nl2br}</tt></td>
<br />
{/if}
+{if $mail.parts_html|@count}
+<table class='bicol' cellpadding='0' cellspacing='0'>
+ {foreach from=$mail.parts_html item=part key=i}
+ <tr><th>Partie n°{$i}</th></tr>
+ <tr class='{cycle values="impair,pair"}'>
+ <td><tt>{$part|qpd|clean_html|nl2br}</tt></td>
+ </tr>
+ {/foreach}
+</table>
+<br />
+{/if}
+
<form method='post' action='{$platal->pl_self(1)}'>
<table class='tinybicol' cellpadding='0' cellspacing='0'>
<tr>