aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src/qgpgmeencryptarchivejob.cpp
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2023-09-22 07:14:34 +0000
committerIngo Klöcker <[email protected]>2023-09-22 08:22:18 +0000
commitd43d787e9ac153f67505fee95a975b4e8f6f928e (patch)
tree5c691b632c179368a5d233c34be1aa6f306796c1 /lang/qt/src/qgpgmeencryptarchivejob.cpp
parentbuild,qt: Autodetect whether Qt was built with -mno-direct-extern-access (diff)
downloadgpgme-d43d787e9ac153f67505fee95a975b4e8f6f928e.tar.gz
gpgme-d43d787e9ac153f67505fee95a975b4e8f6f928e.zip
qt: Use UTF-8 for file names on Windows
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp (decrypt_verify_from_file_name): On Windows, convert Unicode file name to UTF-8. * lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt, encrypt_to_filename): On Windows, convert Unicode file name from/to UTF-8. * lang/qt/src/qgpgmesignarchivejob.cpp (sign, sign_to_filename): Ditto. * lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt, sign_encrypt_to_filename): Ditto. -- On Windows, GnuPG expects file names to be UTF-8-encoded. This fixes encrypting and decrypting folders with umlauts in the folder name and in the file name of the archive. Encrypting and decrypting folders with kanji still fails. GnuPG-bug-id: 6728
Diffstat (limited to 'lang/qt/src/qgpgmeencryptarchivejob.cpp')
-rw-r--r--lang/qt/src/qgpgmeencryptarchivejob.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lang/qt/src/qgpgmeencryptarchivejob.cpp b/lang/qt/src/qgpgmeencryptarchivejob.cpp
index ceab5909..07095ea1 100644
--- a/lang/qt/src/qgpgmeencryptarchivejob.cpp
+++ b/lang/qt/src/qgpgmeencryptarchivejob.cpp
@@ -104,7 +104,11 @@ static QGpgMEEncryptArchiveJob::result_type encrypt(Context *ctx,
flags = static_cast<Context::EncryptionFlags>(flags | Context::EncryptArchive);
const auto encryptionResult = ctx->encrypt(recipients, indata, outdata, flags);
+#ifdef Q_OS_WIN
+ const auto outputFileName = QString::fromUtf8(outdata.fileName());
+#else
const auto outputFileName = QFile::decodeName(outdata.fileName());
+#endif
if (!outputFileName.isEmpty() && encryptionResult.error().code()) {
// ensure that the output file is removed if the operation was canceled or failed
if (QFile::exists(outputFileName)) {
@@ -143,7 +147,11 @@ static QGpgMEEncryptArchiveJob::result_type encrypt_to_filename(Context *ctx,
const QString &baseDirectory)
{
Data outdata;
+#ifdef Q_OS_WIN
+ outdata.setFileName(outputFile.toUtf8().constData());
+#else
outdata.setFileName(QFile::encodeName(outputFile).constData());
+#endif
return encrypt(ctx, recipients, paths, outdata, flags, baseDirectory);
}