From d43d787e9ac153f67505fee95a975b4e8f6f928e Mon Sep 17 00:00:00 2001 From: Ingo Klöcker Date: Fri, 22 Sep 2023 09:14:34 +0200 Subject: 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 --- lang/qt/src/qgpgmesignencryptarchivejob.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lang/qt/src/qgpgmesignencryptarchivejob.cpp') diff --git a/lang/qt/src/qgpgmesignencryptarchivejob.cpp b/lang/qt/src/qgpgmesignencryptarchivejob.cpp index 6670b702..6c28b7ec 100644 --- a/lang/qt/src/qgpgmesignencryptarchivejob.cpp +++ b/lang/qt/src/qgpgmesignencryptarchivejob.cpp @@ -116,7 +116,11 @@ static QGpgMESignEncryptArchiveJob::result_type sign_encrypt(Context *ctx, const auto &signingResult = res.first; const auto &encryptionResult = res.second; +#ifdef Q_OS_WIN + const auto outputFileName = QString::fromUtf8(outdata.fileName()); +#else const auto outputFileName = QFile::decodeName(outdata.fileName()); +#endif if (!outputFileName.isEmpty() && (signingResult.error().code() || encryptionResult.error().code())) { // ensure that the output file is removed if the operation was canceled or failed if (QFile::exists(outputFileName)) { @@ -157,7 +161,11 @@ static QGpgMESignEncryptArchiveJob::result_type sign_encrypt_to_filename(Context const QString &baseDirectory) { Data outdata; +#ifdef Q_OS_WIN + outdata.setFileName(outputFile.toUtf8().constData()); +#else outdata.setFileName(QFile::encodeName(outputFile).constData()); +#endif return sign_encrypt(ctx, signers, recipients, paths, outdata, encryptionFlags, baseDirectory); } -- cgit