refactoring/integrating ARC code

This commit is contained in:
Gene Shuman
2017-01-17 13:20:20 -08:00
parent 697d55d057
commit ac6d9a6bb3
6 changed files with 363 additions and 721 deletions
+351 -534
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -72,7 +72,7 @@ Y+vtSBczUiKERHv1yRbcaQtZFh5wtiRrN04BLUTD21MycBX5jYchHjPY/wIDAQAB"""
# A message verifies after being signed.
sig_lines = dkim.arc_sign(
self.message, b"test", b"example.com", self.key,
"test.domain: none", dkim.CV_None)
b"test.domain: none", dkim.CV_None)
(cv, res, reason) = dkim.arc_verify(b''.join(sig_lines) + self.message, dnsfunc=self.dnsfunc)
self.assertEquals(cv, dkim.CV_Pass)
+8 -4
View File
@@ -16,6 +16,8 @@
#
# Copyright (c) 2011 William Grant <me@williamgrant.id.au>
import re
import logging
try:
from logging import NullHandler
@@ -61,12 +63,14 @@ def parse_tag_value(tag_list):
tag_specs.pop()
for tag_spec in tag_specs:
try:
key, value = tag_spec.split(b'=', 1)
key, value = [x.strip() for x in tag_spec.split(b'=', 1)]
except ValueError:
raise InvalidTagSpec(tag_spec)
if key.strip() in tags:
raise DuplicateTag(key.strip())
tags[key.strip()] = value.strip()
if re.match(br'^[a-zA-Z](\w)*', key) is None:
raise InvalidTagSpec(tag_spec)
if key in tags:
raise DuplicateTag(key)
tags[key] = value
return tags