Incorrect line separator after AAR header

Bug #2049018 reported by Nikolay
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dkimpy
New
Undecided
Unassigned

Bug Description

Given a mail message with '\n' as linesep, generated AAR header ending line separator is '\r\n', which is incorrect. E.g.:

headers == [
    b'ARC-Seal: i=1; cv=none; a=rsa-sha256; d=test1.10-69-41-116.qa.plesk.tech;\n s=default; t=1704968826;\n b=Y2giO87gPbvgBD8YkfBbkNqo457OOWj6ciSEUf1P/GBQZYt42aJyO2d5S7mfWMVYBb1ze\n 7w1CuV8Rgx6tDtvgLcNTOp8vTIUU9T4e/TL6oFnLAOT6RRxoNRWJE+kVWZKqJNy3Hb04aFI\n Pba/BqfQvtbtwjsTnYRaVXn0sFPzvKjUqpddkSFGMjdI96apKpvwGa2I9UWgB0pf5cLpRA3\n GEmS5HfiHcnNa/vq2fp41z7M+D93aMcGhbrz/dXG9V4jt0LCaw6TaZ9S1h5EpycG8pOUsO/\n 1XHBCTZMZ/E14eANQbgML2KfoMr48BUS6YzJifHHPIYY42DL9zouxWBT2qEQ==\n',
    b'ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;\n d=test1.10-69-41-116.qa.plesk.tech; s=default; t=1704968826;\n h=mime-version : date : from : to : subject : message-id :\n content-type : content-transfer-encoding : from;\n bh=AFt2xXGk+vwhUXqU7UsgrZsQKCEGq4uk03cx+GaLyeU=;\n b=ULpRCK1iPfOAYWuCrmFaWrJxzrjH4cLBcFnSs2Zhf6SnQ4rVl3TJR5Zgn7OLD10/wqokG\n q/w4agj0iWioBICZQ+TKIibp7NSwkqHqkIxwv+OeWW0HbInS/7LxOTZK4TcH6t6G9/cMiza\n Fz/TOk6bP1BuKeXgU8WjX38wyA2x3J+UmO7r2l0bGXuexOANtFWVRuO8kwRlp2a32nyAIoX\n Xqhu2OBQAA+BtvCgT5CXfYlvDZ+jNDURj2kR+OXdkVbDrSJJKAOkzQ5qp1imt62r/8wa3WG\n om+fz/1ShbMK1eOqWbyYf5Oz8eXICGFQNo52bDJ8ZWifNuDz9lHcmsIi/6Lw==\n',
    b'ARC-Authentication-Results: i=1; 10-69-41-116.qa.plesk.tech; dmarc=pass (p=QUARANTINE sp=NONE) smtp.from=test1.10-69-41-116.qa.plesk.tech header.from=test1.10-69-41-116.qa.plesk.tech;\n dkim=pass header.d=test1.10-69-41-116.qa.plesk.tech;\n spf=pass (sender IP is 127.0.0.1) <email address hidden> smtp.helo=webmail.test1.10-69-41-116.qa.plesk.tech\r\n'
]
message[:80] == b'Return-Path: <email address hidden>\nX-Original-To: mail1@test1'

When assembling the resulting message this produces headers with inconsistent line separators. This, in turn, results in certain clients (such as Outlook) incorrectly displaying the message (showing headers instead of / in addition to body).

Library version: dkimpy==1.1.5

This is fixed with the following patch:

--- dkim/__init__.py.orig 2024-01-11 10:31:46.157334161 +0000
+++ dkim/__init__.py 2024-01-11 10:43:07.247551542 +0000
@@ -1120,8 +1120,7 @@
       arc_headers = []

     # Compute ARC-Authentication-Results
- aar_value = ("i=%d; " % instance).encode('utf-8') + auth_results
- if aar_value[-1] != b'\n': aar_value += b'\r\n'
+ aar_value = ("i=%d; " % instance).encode('utf-8') + auth_results.rstrip() + self.linesep

     new_arc_set.append(b"ARC-Authentication-Results: " + aar_value)
     self.headers.insert(0, (b"arc-authentication-results", aar_value))

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.