Merge branch 'master' into javascript-binding

This commit is contained in:
Maximilian Krambach 2018-05-09 16:55:50 +02:00
commit 5f5bf024a8
5 changed files with 35 additions and 14 deletions

View File

@ -88,7 +88,7 @@ Name-Real: Joe Tester
Name-Comment: with stupid passphrase Name-Comment: with stupid passphrase
Name-Email: joe+gpg@example.org Name-Email: joe+gpg@example.org
Passphrase: Crypt0R0cks Passphrase: Crypt0R0cks
Expire-Date: 2020-12-31 Expire-Date: 2099-12-31
</GnupgKeyParms> </GnupgKeyParms>
""" """

View File

@ -19,6 +19,12 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA # 02111-1307, USA
SUBDIRS = src tests doc if RUN_GPG_TESTS
tests = tests
else
tests =
endif
SUBDIRS = src ${tests} doc
EXTRA_DIST = README EXTRA_DIST = README

View File

@ -42,6 +42,7 @@
#include "gpgme_backend_debug.h" #include "gpgme_backend_debug.h"
#include <QFile> #include <QFile>
#include <QDir>
#include "global.h" #include "global.h"
#include "error.h" #include "error.h"
@ -521,8 +522,7 @@ QUrl QGpgMENewCryptoConfigEntry::urlValue() const
Q_ASSERT(type == FilenameType || type == LdapServerType); Q_ASSERT(type == FilenameType || type == LdapServerType);
Q_ASSERT(!isList()); Q_ASSERT(!isList());
if (type == FilenameType) { if (type == FilenameType) {
QUrl url; QUrl url = QUrl::fromLocalFile(m_option.currentValue().stringValue());
url.setPath(QFile::decodeName(m_option.currentValue().stringValue()));
return url; return url;
} }
return parseURL(type, stringValue()); return parseURL(type, stringValue());
@ -635,7 +635,7 @@ void QGpgMENewCryptoConfigEntry::setURLValue(const QUrl &url)
if (str.isEmpty() && !isOptional()) { if (str.isEmpty() && !isOptional()) {
m_option.resetToDefaultValue(); m_option.resetToDefaultValue();
} else if (type == FilenameType) { } else if (type == FilenameType) {
m_option.setNewValue(m_option.createStringArgument(QFile::encodeName(str).constData())); m_option.setNewValue(m_option.createStringArgument(QDir::toNativeSeparators(url.toLocalFile()).toUtf8().constData()));
} else { } else {
m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData())); m_option.setNewValue(m_option.createStringArgument(str.toUtf8().constData()));
} }

View File

@ -1013,8 +1013,17 @@ status_handler (void *opaque, int fd)
*(rest++) = 0; *(rest++) = 0;
r = _gpgme_parse_status (line + 2); r = _gpgme_parse_status (line + 2);
if (gpgsm->status.mon_cb && r != GPGME_STATUS_PROGRESS)
{
/* Note that we call the monitor even if we do
* not know the status code (r < 0). */
err = gpgsm->status.mon_cb (gpgsm->status.mon_cb_value,
line + 2, rest);
}
else
err = 0;
if (r >= 0) if (r >= 0 && !err)
{ {
if (gpgsm->status.fnc) if (gpgsm->status.fnc)
{ {

View File

@ -610,7 +610,8 @@ make_data_object (cjson_t result, gpgme_data_t data, size_t chunksize,
{ {
gpg_error_t err; gpg_error_t err;
char *buffer; char *buffer;
size_t buflen; const char *s;
size_t buflen, n;
int c; int c;
if (!base64 || base64 == -1) /* Make sure that we really have a string. */ if (!base64 || base64 == -1) /* Make sure that we really have a string. */
@ -629,13 +630,18 @@ make_data_object (cjson_t result, gpgme_data_t data, size_t chunksize,
base64 = 0; base64 = 0;
if (!buflen) if (!buflen)
log_fatal ("Appended Nul byte got lost\n"); log_fatal ("Appended Nul byte got lost\n");
if (memchr (buffer, 0, buflen-1)) /* Figure out if there is any Nul octet in the buffer. In that
{ * case we need to Base-64 the buffer. Due to problems with the
buflen--; /* Adjust for the extra nul byte. */ * browser's Javascript we use Base-64 also in case an UTF-8
base64 = 1; * character is in the buffer. This is because the chunking may
} * split an UTF-8 characters and JS can't handle this. */
/* Fixme: We might want to do more advanced heuristics than to for (s=buffer, n=0; n < buflen -1; s++, n++)
* only look for a Nul. */ if (!*s || (*s & 0x80))
{
buflen--; /* Adjust for the extra nul byte. */
base64 = 1;
break;
}
} }
/* Adjust the chunksize if we need to do base64 conversion. */ /* Adjust the chunksize if we need to do base64 conversion. */