From b8d56260413113b86816a92a5a27ad9c06a3a2c7 Mon Sep 17 00:00:00 2001 From: Dominik Chilla Date: Thu, 10 Dec 2020 17:07:58 +0100 Subject: [PATCH] 5322 header parsing case-insensitive --- app/exota-milter.py | 6 +++--- tests/miltertest.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/exota-milter.py b/app/exota-milter.py index 1c46b5e..72ebec2 100644 --- a/app/exota-milter.py +++ b/app/exota-milter.py @@ -123,7 +123,7 @@ class ExOTAMilter(Milter.Base): ) # Parse RFC-5322-From header - if(name == "From"): + if(name.lower() == "From".lower()): hdr_5322_from = email.utils.parseaddr(hval) self.hdr_from = hdr_5322_from[1].lower() m = re.match(g_re_domain, self.hdr_from) @@ -140,7 +140,7 @@ class ExOTAMilter(Milter.Base): ) # Parse non-standardized X-MS-Exchange-CrossTenant-Id header - elif(name == "X-MS-Exchange-CrossTenant-Id"): + elif(name.lower() == "X-MS-Exchange-CrossTenant-Id".lower()): self.hdr_tenant_id_count += 1 self.hdr_tenant_id = hval.lower() logging.debug(self.mconn_id + "/" + str(self.getsymval('i')) + @@ -148,7 +148,7 @@ class ExOTAMilter(Milter.Base): ) # Parse RFC-7601 Authentication-Results header - elif(name == "Authentication-Results"): + elif(name.lower() == "Authentication-Results".lower()): if g_milter_dkim_enabled == True: ar = None try: diff --git a/tests/miltertest.lua b/tests/miltertest.lua index 0a8b4e5..5df6209 100644 --- a/tests/miltertest.lua +++ b/tests/miltertest.lua @@ -27,10 +27,10 @@ if mt.getreply(conn) ~= SMFIR_CONTINUE then end -- HEADER -if mt.header(conn, "From", '"Blah Blubb" ') ~= nil then +if mt.header(conn, "fRoM", '"Blah Blubb" ') ~= nil then error "mt.header(From) failed" end -if mt.header(conn, "X-MS-Exchange-CrossTenant-Id", "1234abcd-18c5-45e8-88de-123456789abc") ~= nil then +if mt.header(conn, "x-mS-EXCHANGE-crosstenant-id", "1234abcd-18c5-45e8-88de-123456789abc") ~= nil then error "mt.header(Subject) failed" end --if mt.header(conn, "X-MS-Exchange-CrossTenant-Id", "4321abcd-18c5-45e8-88de-blahblubb") ~= nil then @@ -45,7 +45,7 @@ end if mt.header(conn, "Authentication-Results", "my-auth-serv-id;\n exota=pass") ~= nil then error "mt.header(Subject) failed" end -if mt.header(conn, "Authentication-Results", "my-auth-serv-id;\n dkim=pass header.d=yad.onmicrosoft.com header.s=selector1-yad-onmicrosoft-com header.b=mmmjFpv8") ~= nil then +if mt.header(conn, "Authentication-RESULTS", "my-auth-serv-id;\n dkim=pass header.d=yad.onmicrosoft.com header.s=selector1-yad-onmicrosoft-com header.b=mmmjFpv8") ~= nil then error "mt.header(Subject) failed" end if mt.header(conn, "Authentication-Results", "my-auth-serv-id;\n dkim=fail header.d=yad.onmicrosoft.com header.s=selector2-asdf header.b=mmmjFpv8") ~= nil then