Unverified Commit b328227c authored by Rolf Eike Beer's avatar Rolf Eike Beer
Browse files

always close the input channel of a text decryption

Otherwise the decryption never starts with GnuPG 2.3.

BUG:444848
parent a1d7c5ae
Pipeline #120048 passed with stage
in 2 minutes and 38 seconds
......@@ -145,3 +145,10 @@ KGpgDecrypt::finish()
KGpgTextOrFileTransaction::finish();
}
}
bool KGpgDecrypt::closeInputAfterText() const
{
// otherwise decryption does never start in GnuPG 2.3,
// but doesn't hurt on older versions as well
return true;
}
......@@ -68,7 +68,7 @@ protected:
QStringList command() const override;
bool nextLine(const QString &line) override;
void finish() override;
bool closeInputAfterText() const override;
private:
int m_fileIndex;
......
......@@ -112,10 +112,15 @@ KGpgTextOrFileTransaction::preStart()
args << command();
// if the input is not stdin set command-fd so GnuPG
// can ask if e.g. the file already exists
m_closeInput = !args.contains(QLatin1String("--command-fd=0"));
if (m_closeInput && (!locfiles.isEmpty() || !m_tempfiles.isEmpty())) {
args << QLatin1String("--command-fd=0");
bool hasCFd = !args.contains(QLatin1String("--command-fd=0"));
if (!locfiles.isEmpty() || !m_tempfiles.isEmpty()) {
if (!hasCFd)
args << QLatin1String("--command-fd=0");
m_closeInput = false;
} else if (closeInputAfterText()) {
m_closeInput = true;
} else {
m_closeInput = hasCFd;
}
if (locfiles.count() + m_tempfiles.count() > 1)
args << QLatin1String("--multifile");
......
......@@ -85,6 +85,18 @@ protected:
const QList<QUrl> &getInputFiles() const;
/**
* @brief if the input channel of GnuPG should be closed when text is written
*
* This only has an effect in text mode (i.e. without urls).
*
* If not given the input channel is closed when "--command-fd" is not used.
*/
virtual bool closeInputAfterText() const
{
return false;
}
private:
QStringList m_tempfiles;
QStringList m_locfiles;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment