diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2008-09-20 12:49:14 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2008-09-20 12:49:14 +0000 |
commit | 946464f3858050d6e6749702310faba94c287903 (patch) | |
tree | 3d04b23a5e399789d39f7046688b0064c30cd767 | |
parent | gpgwin.*, ported r152,r153,r156 (import key from clipboard/import-dialog) fro... (diff) | |
download | gpg4usb-946464f3858050d6e6749702310faba94c287903.tar.gz gpg4usb-946464f3858050d6e6749702310faba94c287903.zip |
gpgwin.*, ported r157 (simple fix for 'NO DATA'-error) from trunk
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.1@167 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpgwin.cpp | 17 | ||||
-rw-r--r-- | gpgwin.h | 1 | ||||
-rw-r--r-- | release/keydb/pubring.gpg | bin | 1166 -> 2093 bytes |
3 files changed, 17 insertions, 1 deletions
@@ -384,13 +384,28 @@ void GpgWin::encrypt() void GpgWin::decrypt() { QByteArray *tmp = new QByteArray(); - myCtx->decrypt(edit->toPlainText().toAscii(), tmp); + QByteArray text = edit->toPlainText().toAscii(); + preventNoDataErr(&text); + myCtx->decrypt(text, tmp); if (!tmp->isEmpty()) { QString *tmp2 = new QString(*tmp); edit->setPlainText(*tmp2); } } +/** + * if there is no '\n' before the PGP-Begin-Block, but for example a whitespace, + * GPGME doesn't recognise the Message as encrypted. This function adds '\n' + * before the PGP-Begin-Block, if missing. + */ +void GpgWin::preventNoDataErr(QByteArray *in) +{ + int block_start = in->indexOf("-----BEGIN PGP MESSAGE-----"); + if(block_start > 0 && in->at(block_start - 1) != '\n') { + in->insert(block_start, '\n'); + } +} + void GpgWin::importKeyFromEdit() { myCtx->importKey(edit->toPlainText().toAscii()); @@ -68,6 +68,7 @@ private: void setCurrentFile(const QString &fileName); bool maybeSave(); QString strippedName(const QString &fullFileName); + void preventNoDataErr(QByteArray *in); QPlainTextEdit *edit; QMenu *fileMenu; diff --git a/release/keydb/pubring.gpg b/release/keydb/pubring.gpg Binary files differindex acb4872..98ece8c 100644 --- a/release/keydb/pubring.gpg +++ b/release/keydb/pubring.gpg |