PDF: fix the encoding for the file name of attachments

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 <aacid@kde.org>
(cherry picked from commit 0effdc98dcaaf4fab118f9834f67b4d5d3107d7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2024-05-23 10:34:55 +02:00 committed by Qt Cherry-pick Bot
parent 6197078fbd
commit a3e37975e1

View File

@ -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 <</F %d 0 R>>\n"
"/Type/Filespec\n"