Validate input file name

Dieser Commit ist enthalten in:
Axel Svensson 2022-10-19 17:56:46 +02:00
Ursprung 216d9c2668
Commit e8c77cfedd

Datei anzeigen

@ -9,6 +9,8 @@ signatureDir=os.path.expanduser(os.environ['PDF_SIGNATURE_DIR'] if 'PDF_SIGNATUR
# Inspired by https://unix.stackexchange.com/a/141496
def main(args):
filePath=args.input
if not m("^.*\.(pdf|PDF)$", filePath):
die("Input file must end with .pdf or .PDF")
with tempfile.TemporaryDirectory() as tempdir:
intmp=lambda fileName: os.path.join(tempdir, fileName)
# Maybe flatten (make forms non-editable) before signing