From 7df096cffe4806fbc1e13fbcc3170933876a115a Mon Sep 17 00:00:00 2001 From: nils Date: Tue, 11 Oct 2011 20:29:14 +0000 Subject: moved preventnodataerr to context.cpp, added refresh slots for verify git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@544 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- context.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'context.cpp') diff --git a/context.cpp b/context.cpp index b55467a..87b6c3f 100644 --- a/context.cpp +++ b/context.cpp @@ -615,6 +615,24 @@ bool Context::sign(QStringList *uidList, const QByteArray &inBuffer, QByteArray return (err == GPG_ERR_NO_ERROR); } + +/* + * 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 Context::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'); + } + block_start = in->indexOf("-----BEGIN PGP SIGNED MESSAGE-----"); + if (block_start > 0 && in->at(block_start - 1) != '\n') { + in->insert(block_start, '\n'); + } +} + } -- cgit