1

Topic: BUG: Quarantine View shows duplicate Received headers

==== Required information ====
- iRedMail version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
======== Required information ====
- iRedMail version: 0.8.6
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version:  Debian Wheezy
- Related log if you're reporting an issue:
====

Received Headers are not extracted correctly. The first header is shown multiple times.
See screenshot in comaprison to mail.

Greets,
Frank

Post's attachments

iredadmin_activities_quarantined.jpg 112 kb, 1 downloads since 2014-04-23 

mail.txt 1.92 kb, 4 downloads since 2014-04-23 

You don't have the permssions to download the attachments of this post.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: BUG: Quarantine View shows duplicate Received headers

I see 'Received:' is duplicate here and it doesn't show second 'Received:'. Other mail headers are just fine.

The first header is "X-Envelope-To", no duplicate here.

3

Re: BUG: Quarantine View shows duplicate Received headers

This issue has existed for some time now, I've reported this in the past as well and was ignored then too. perhaps the issue isn't clear?

==== Required information ====
- iRedMail version: 0.8.6 & 0.8.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): ldap
- Linux/BSD distribution name and version: CentOS release 6.5 (Final)
- Related log if you're reporting an issue:
====

The issue is that the first 'Received:' header is duplicated rather than showing all headers. Comparing the received headers with what the quarantine page is displaying you should see what I mean.

'Received:' headers of the original message:

Received: from mail1.private-pages.com ([127.0.0.1])
           by localhost (mail1.private-pages.com [127.0.0.1]) (amavisd-new, port 10024)
           with ESMTP id mNi1ypuzS2gR for <XXXXXXXX@XXXXXXX.XXX>;
           Sun, 18 May 2014 10:53:21 +0200 (CEST)
Received: from server2.ictraining.com (unknown [76.76.9.149])
           by mail1.private-pages.com (Postfix) with ESMTPS id 7C4E841F9
           for <XXXXXXXX@XXXXXXXX.XXX>; Sun, 18 May 2014 10:53:21 +0200 (CEST)
Received: from [64.235.43.97] (port=49366 helo=ax.nl)
           by server2.ictraining.com with esmtpa (Exim 4.82)
           (envelope-from <no-reply@ax.nl>)
           id 1Wkue9-0005c1-Bw; Thu, 15 May 2014 05:20:25 -0700

Headers as displayed on the quarantine page:

Received    from mail1.private-pages.com ([127.0.0.1])
                by localhost (mail1.private-pages.com [127.0.0.1]) (amavisd-new, port 10024)
                with ESMTP id mNi1ypuzS2gR for <XXXXXXX@XXXXXXXX.XXX>;
                Sun, 18 May 2014 10:53:21 +0200 (CEST)
Received    from mail1.private-pages.com ([127.0.0.1])
                by localhost (mail1.private-pages.com [127.0.0.1]) (amavisd-new, port 10024)
                with ESMTP id mNi1ypuzS2gR for <XXXXXXX@XXXXXXXX.XXX>;
                Sun, 18 May 2014 10:53:21 +0200 (CEST)
Received    from mail1.private-pages.com ([127.0.0.1])
                by localhost (mail1.private-pages.com [127.0.0.1]) (amavisd-new, port 10024)
                with ESMTP id mNi1ypuzS2gR for <XXXXXXX@XXXXXXXX.XXX>;
                Sun, 18 May 2014 10:53:21 +0200 (CEST)

As you can see the first 'Received:' header of the original message is shown 3 times on the quarantine page, the second and third 'Received:' headers are not shown on the quarantine page at all. This happens for every message in quarantine.

4

Re: BUG: Quarantine View shows duplicate Received headers

This actually happens for every header that occurs more than once. I think the issue here is that the header names are used as key in the key->value pairs for the headers which makes them not unique.

5

Re: BUG: Quarantine View shows duplicate Received headers

I will check this issue and try to solve it in future release, thanks for your feedback.

6

Re: BUG: Quarantine View shows duplicate Received headers

Hi srd2010, taco,

I fixed duplicate 'Received' header issue, here's patch for the latest 2 releases of iRedAdmin-Pro:

diff -r bba9eecae6de libs/mailparser.py
--- a/libs/mailparser.py    Wed May 21 21:21:35 2014 +0800
+++ b/libs/mailparser.py    Thu May 22 11:45:16 2014 +0800
@@ -9,32 +9,17 @@
 def _decode_headers(msg, default_character_set='ascii'):
     """Decode message into (header, value) pairs."""
 
-    # Get all mail headers.
-    headers = msg.keys()
+    # List of {header: value} pairs.
+    headers = []
 
-    # List of {header: value}. Sample:
-    # [
-    #   {'From': 'sender@domain.ltd', 'To': 'recipient@example.com',},
-    # ]
-    headers_values = []
+    for (header, value) in msg.items():
+        value = u' '.join([
+            unicode(text, charset or default_character_set)
+            for text, charset in decode_header(value)
+        ])
+        headers += [{header: value}]
 
-    for h in headers:
-        # Skip non-exist headers.
-        if not h in msg:
-            continue
-
-        try:
-            # Decode header value to list of (decoded_string, charset) pairs.
-            # Convert into unicode.
-            header_value = u' '.join([
-                unicode(text, charset or default_character_set)
-                for text, charset in decode_header(msg[h])
-            ])
-            headers_values += [{h: header_value}]
-        except:
-            pass
-
-    return headers_values
+    return headers
 
 

7

Re: BUG: Quarantine View shows duplicate Received headers

Hi ZhangHuangbin,

I didn't see your reply until now, I didn't receive a notification.

I've applied the patch and can confirm it's working now smile
Thanks!