From 5ccddae7f5a4482d0868158f19ceddf8a20c9225 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 28 Mar 2022 22:34:57 +0200 Subject: [PATCH] Fix the PDF version This should prevent the testsuite from breaking, and marginally increase fingerprinting resistance. --- libmat2/pdf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmat2/pdf.py b/libmat2/pdf.py index ff12fc2..b79c7c7 100644 --- a/libmat2/pdf.py +++ b/libmat2/pdf.py @@ -22,6 +22,7 @@ if LooseVersion(poppler_version) < LooseVersion('0.46'): # pragma: no cover raise ValueError("mat2 needs at least Poppler version 0.46 to work. \ The installed version is %s." % poppler_version) # pragma: no cover +FIXED_PDF_VERSION = cairo.PDFVersion.VERSION_1_5 class PDFParser(abstract.AbstractParser): mimetypes = {'application/pdf', } @@ -52,6 +53,7 @@ class PDFParser(abstract.AbstractParser): tmp_path = tempfile.mkstemp()[1] pdf_surface = cairo.PDFSurface(tmp_path, 10, 10) # resized later anyway + pdf_surface.restrict_to_version(FIXED_PDF_VERSION) pdf_context = cairo.Context(pdf_surface) # context draws on the surface for pagenum in range(pages_count): @@ -80,6 +82,7 @@ class PDFParser(abstract.AbstractParser): _, tmp_path = tempfile.mkstemp() pdf_surface = cairo.PDFSurface(tmp_path, 32, 32) # resized later anyway + pdf_surface.restrict_to_version(FIXED_PDF_VERSION) pdf_context = cairo.Context(pdf_surface) for pagenum in range(pages_count):