From a3e37975e12c9d0515339cf4bb0e1087baebc9c5 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 23 May 2024 10:34:55 +0200 Subject: [PATCH] PDF: fix the encoding for the file name of attachments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A file specification in PDF is a string (ยง3.10.1 of the PDF 1.6 spec). As such, it needs to be properly encoded. Right now the code was doing a naive conversion to latin1 (which was lossy), and was not considering things like round parenthesis which need to be properly escaped. Just use printString instead. This work has been kindly sponsored by the QGIS project (https://qgis.org/). Change-Id: Icdcf8b553955d31fe2bc430dea54bb6e68221fc7 Pick-to: 6.5 Reviewed-by: Albert Astals Cid (cherry picked from commit 0effdc98dcaaf4fab118f9834f67b4d5d3107d7a) Reviewed-by: Qt Cherry-pick Bot --- src/gui/painting/qpdf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index d49249b1dda..42c0ec9e217 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1843,7 +1843,8 @@ void QPdfEnginePrivate::writeAttachmentRoot() attachments.push_back(addXrefEntry(-1)); xprintf("<<\n" - "/F (%s)", attachment.fileName.toLatin1().constData()); + "/F "); + printString(attachment.fileName); xprintf("\n/EF <>\n" "/Type/Filespec\n"