5322 header parsing case-insensitive

This commit is contained in:
Dominik Chilla 2020-12-10 17:07:58 +01:00
parent 88caa0e9d6
commit b8d5626041
2 changed files with 6 additions and 6 deletions

View File

@ -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:

View File

@ -27,10 +27,10 @@ if mt.getreply(conn) ~= SMFIR_CONTINUE then
end
-- HEADER
if mt.header(conn, "From", '"Blah Blubb" <O365ConnectorValidation@yad.onmicrosoft.com>') ~= nil then
if mt.header(conn, "fRoM", '"Blah Blubb" <O365ConnectorValidation@yad.onmicrosoft.com>') ~= 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