aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--emails/mricon-signed.eml10
-rwxr-xr-xmain.py29
2 files changed, 10 insertions, 29 deletions
diff --git a/emails/mricon-signed.eml b/emails/mricon-signed.eml
index 1dbab79..5bd8550 100644
--- a/emails/mricon-signed.eml
+++ b/emails/mricon-signed.eml
@@ -8,11 +8,11 @@ X-Mailer: git-send-email 2.25.4
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
-X-Developer-Signature: v=1; a=openpgp-sha256; h=from:subject:date:message-id;
- l=1002; bh=g2Sv1ZR+jIrWukzdXbqb+aeiqyFQOBLDQY6z0BBnGg4=;
- b=owGbwMvMwCG27YjM47CUmTmMp9WSGBK6HqX59M4tN5m8hjEiwZTDJmfF48BvJ05sOPb0+nf7xud3
- F4dkdpSyMIhxMMiKKbKU7YvdFFT40EMuvccUZg4rE8gQBi5OAZiI+zVGhrN5zlGrfzm2Szwu1yrMOn
- dXtCqXv9GD37Mub+KRL8XyKxj+5+1e6bXhatwym+6pUw5x7z4dE5l7yPJE+7GNPzY9a5fm4wUA
+X-Developer-Signature: v=1; a=openpgp-sha256; h=from:subject:date:message-id;
+ l=1002; bh=g2Sv1ZR+jIrWukzdXbqb+aeiqyFQOBLDQY6z0BBnGg4=;
+ b=owGbwMvMwCG27YjM47CUmTmMp9WSGBK6VbV9eueWm0xewxiRYMphk7PiceC3Eyc2HHt6/bt94/O7
+ i0MyO0pZGMQ4GGTFFFnK9sVuCip86CGX3mMKM4eVCWQIAxenAEwkrIqR4dTlkIg79k0XLfVXCUqm1P
+ ewSUm83fVx0uuLe75FX23+MZ2RYc5x74PN077Fe+wszuvedD7M7O6OsOJAI0uvtxFurHFf2QA=
This addresses the following gcc warning with "make W=1":
diff --git a/main.py b/main.py
index 2e732e3..8d7e5a0 100755
--- a/main.py
+++ b/main.py
@@ -5,6 +5,7 @@ import sys
import os
import base64
import email.utils
+import email.header
import re
import subprocess
import hashlib
@@ -157,28 +158,6 @@ def splitter(longstr: bytes, limit: int = 78) -> bytes:
return b' '.join(splitstr)
-def folder(longhdr: bytes, limit: int = 78) -> bytes:
- lines = list()
- line = b''
- for chunk in longhdr.split(b' '):
- if len(line + chunk) > limit:
- lines.append(line)
- line = b''
- if len(chunk) > limit:
- # the chunk itself is longer than limit, so append it as-is
- lines.append(b' ' + chunk)
- continue
- if not len(lines) and not len(line):
- # We're at the very start, so no need to prepend with ' '
- line += chunk
- else:
- line += b' ' + chunk
- if len(line):
- lines.append(line)
-
- return b'\r\n'.join(lines)
-
-
def get_git_toplevel(gitdir: str = None) -> str:
cmdargs = ['git']
if gitdir:
@@ -400,7 +379,8 @@ def cmd_sign_ed25519(cmdargs) -> None:
sys.exit(1)
bdata = sk.sign(digest, encoder=Base64Encoder)
- dshdr = folder(dshdr + splitter(bdata))
+ hhdr = email.header.make_header([(dshdr + splitter(bdata), 'us-ascii')], maxlinelen=78)
+ dshdr = hhdr.encode().encode()
headers.append(dshdr)
signed = b'\r\n'.join(headers) + b'\r\n\r\n' + payload
logger.info('--- SIGNED MESSAGE STARTS ---')
@@ -430,7 +410,8 @@ def cmd_sign_pgp(cmdargs) -> None:
logger.critical(err.decode())
sys.exit(ecode)
bdata = base64.b64encode(out)
- dshdr = folder(dshdr + splitter(bdata))
+ hhdr = email.header.make_header([(dshdr + splitter(bdata), 'us-ascii')], maxlinelen=78)
+ dshdr = hhdr.encode().encode()
headers.append(dshdr)
signed = b'\r\n'.join(headers) + b'\r\n\r\n' + payload
logger.info('--- SIGNED MESSAGE STARTS ---')