[poppler] utils/pdfattach.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 24 21:21:56 UTC 2022
utils/pdfattach.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
New commits:
commit 3d8e5e005fb553147c2a4a6d7327c98896221faa
Author: Albert Astals Cid <aacid at kde.org>
Date: Mon May 9 00:44:16 2022 +0200
pdfattach: Assume filename is utf8 encoded
Which is the encoding most [linux] OS use
Fixes issue #1079
diff --git a/utils/pdfattach.cc b/utils/pdfattach.cc
index dd16bed3..96d6f0f6 100644
--- a/utils/pdfattach.cc
+++ b/utils/pdfattach.cc
@@ -21,6 +21,7 @@
#include "PDFDocFactory.h"
#include "Error.h"
#include "ErrorCodes.h"
+#include "UTF.h"
#include "Win32Console.h"
static bool doReplace = false;
@@ -85,14 +86,14 @@ int main(int argc, char *argv[])
return 3;
}
- const std::string attachFileName = gbasename(attachFilePath.c_str());
+ const std::unique_ptr<GooString> attachFileName = utf8ToUtf16WithBom(gbasename(attachFilePath.c_str()));
- if (!doReplace && doc->getCatalog()->hasEmbeddedFile(attachFileName)) {
- fprintf(stderr, "There is already an embedded file named %s.\n", attachFileName.c_str());
+ if (!doReplace && doc->getCatalog()->hasEmbeddedFile(attachFileName->toStr())) {
+ fprintf(stderr, "There is already an embedded file named %s.\n", attachFileName->c_str());
return 4;
}
- doc->getCatalog()->addEmbeddedFile(attachFile.get(), attachFileName);
+ doc->getCatalog()->addEmbeddedFile(attachFile.get(), attachFileName->toStr());
const GooString outputPdfFilePath(argv[3]);
const int saveResult = doc->saveAs(outputPdfFilePath);
More information about the poppler
mailing list