commit 12124f9e0bba128182f284d248ce45a1bf7aeb85
parent 0b4716e6566bce0b3218df96830099299074b5c6
Author: Dominik Hofer <dominik.hofer@bfh.ch>
Date: Fri, 6 Dec 2019 10:05:06 +0100
Merge branch 'master' of git+ssh://git.taler.net/taler-mdb
Diffstat:
| M | src/main.c | | | 36 | +++++++++++++++++++++++++++++++----- |
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -551,11 +551,29 @@ show_qrcode (const char *uri)
QRcode *qrc;
unsigned int size;
char *upper;
+ char *base;
size_t xOff;
size_t yOff;
+ const char *dddash;
if (0 > qrDisplay.devicefd)
return; /* no display, no dice */
+ /* find the fourth '/' in the payto://pay/hostname/-uri */
+ dddash = strchr (uri, '/');
+ if (NULL != dddash)
+ dddash = strchr (dddash + 1, '/');
+ if (NULL != dddash)
+ dddash = strchr (dddash + 1, '/');
+ if (NULL != dddash)
+ dddash = strchr (dddash + 1, '/');
+ if (NULL == dddash)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "taler://pay/-URI malformed: `%s'\n",
+ uri);
+ return;
+ }
+
qri = QRinput_new2 (0, QR_ECLEVEL_L);
if (NULL == qri)
{
@@ -563,10 +581,18 @@ show_qrcode (const char *uri)
"QRinput_new2");
return;
}
- upper = GNUNET_strdup (uri);
- /* NOTE: this line fails, Taler wallet likes URIs only lower-case!
- => Wallet bug! */
- /* GNUNET_STRINGS_utf8_toupper (uri, upper); */
+ /* convert all characters until the fourth '/' to upper
+ case. The rest _should_ be upper case in a NICE setup,
+ but we can't warrant it and must not touch those. */
+ base = GNUNET_strndup (uri,
+ dddash - uri);
+
+ GNUNET_STRINGS_utf8_toupper (base, base);
+ GNUNET_asprintf (&upper,
+ "%s%s",
+ base,
+ dddash);
+ GNUNET_free (base);
/* first try encoding as uppercase-only alpha-numerical
QR code (much smaller encoding); if that fails, also
try using binary encoding (in case nick contains
@@ -1540,7 +1566,7 @@ write_mdb_command (void *cls)
chkSum += mdb.txBuffer[idx] = mdb.cmd->cmd.bin[idx];
for (size_t idx = 0; idx < mdb.cmd->data.bin_size; idx++)
chkSum += mdb.txBuffer[idx + mdb.cmd->cmd.bin_size] =
- mdb.cmd->data.bin[idx];
+ mdb.cmd->data.bin[idx];
mdb.txBuffer[mdb.cmd->cmd.bin_size + mdb.cmd->data.bin_size] =
(uint8_t) (chkSum & 0xFF);
}