From 9503fd60b0763f0567c31896dc5cf2a6f05cadec Mon Sep 17 00:00:00 2001 From: Diskette Guy Date: Thu, 16 Oct 2025 04:01:34 +0700 Subject: [PATCH] Final commit, I've learned my lesson --- Cheatsheet.txt | 3 +++ dkim/__init__.py | 2 ++ dkim/__main__.py | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cheatsheet.txt b/Cheatsheet.txt index d274a43..c33f887 100644 --- a/Cheatsheet.txt +++ b/Cheatsheet.txt @@ -18,6 +18,9 @@ Python's __main__ and __init__ As far as I know, __init__ is the initialization script, just like Unix and alike's /etc/init.rc script. It's required to make it so that it's a package. The double underscores is for signifying that it's a global variable. +b before string, for example b'relaxed' is a way to say that it's a binary string + + -----START DKIM DIRECTORY----- [__init__] diff --git a/dkim/__init__.py b/dkim/__init__.py index 2411bc1..6374088 100644 --- a/dkim/__init__.py +++ b/dkim/__init__.py @@ -301,6 +301,7 @@ def validate_signature_fields(sig, mandatory_fields=[b'v', b'a', b'b', b'bh', b' if b'cv' in sig and sig[b'cv'] not in (CV_Pass, CV_Fail, CV_None): raise ValidationError("cv= value is not valid (%s)" % sig[b'cv']) + # Somehow convert it to UTF8 before going to this? # Limit domain validation to ASCII domains because too hard try: str(sig[b'd'], 'ascii') @@ -311,6 +312,7 @@ def validate_signature_fields(sig, mandatory_fields=[b'v', b'a', b'b', b'bh', b' # Not an ASCII domain pass + # Nasty hack to support both str and bytes... check for both the # character and integer values. if not arc and b'i' in sig and ( diff --git a/dkim/__main__.py b/dkim/__main__.py index 1e0a02f..1f1b190 100644 --- a/dkim/__main__.py +++ b/dkim/__main__.py @@ -1,7 +1,7 @@ import unittest import doctest import dkim -from tests import test_suite +from dkim.tests import test_suite doctest.testmod(dkim) unittest.TextTestRunner().run(test_suite())