lieser / dkim_verifier

DKIM Verifier Extension for Mozilla Thunderbird
MIT License
210 stars 35 forks source link

Misrepresentation of whitespace #43

Closed Afwas closed 9 years ago

Afwas commented 9 years ago

Emails sent to myself get an error: Invalid (Copied header fields tag ill-formed) Investigating I foud this DEBUG in console:

DKIM_Verifier.Verifier  WARN DKIM_SIGERROR_ILLFORMED_Z: DKIM Signature Error: Copied header fields tag ill-formed (resource://dkim_verifier/helper.jsm:5) JS Stack trace: parseTagValue@dkimVerifier.jsm:329:5 < parseDKIMSignature@dkimVerifier.jsm:636:7 < processSignatures@dkimVerifier.jsm:1133:5 < Verifier_verify2@dkimVerifier.jsm:1320:7 < _authVerifier_verify/promise<@AuthVerifier.jsm:107:9

So it's the z= tag. Removing my personal information the z= tag from this email looks like

z=From:=20foo@example.comt|To:=20bar@example.net|Subject:=20Het=2 0weer=20te=20Garnwerd=20in=20de=20maand=20maart=202015|Date:=20Thu ,=2019=20Mar=202015=2004:36:33=20+0100=20(CET); 

Examining the code with help from the backtrace from the DEBUG information I think the bug could be in the pattWSP regexp [ \t] in dkimVerifier.jsm:101 which is misrepresenting the whitespace in the z= tag becasue the space in the z= tag is converted to =20 which is the Unicode cahracter value of the space \u0020.

But I might be wrong ;)

lieser commented 9 years ago

The problem is the space in the encoded space =20 which is not allowed ( ... |Subject:=20Het=2 0weer=20te=20 ...). If I remove it the add-on no longer gives this error. So this seems not to be an error in the add-on, but a problem at the signer or in the transport

lieser commented 7 years ago

I had a second lock at the RFC, and came to the conclusion that I was probably wrong. As long as it was not just a space, but a folding whitespace (multiple lines separated by CRLF followed by at least one whitespace) it is probably allowed. The behavior of the add-on will be changed in version 1.6.2.