[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-mdb] branch master updated: convert prefix and hostname to
From: |
gnunet |
Subject: |
[taler-taler-mdb] branch master updated: convert prefix and hostname to upper case for compact QR codes |
Date: |
Fri, 06 Dec 2019 09:12:29 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository taler-mdb.
The following commit(s) were added to refs/heads/master by this push:
new 842c4a6 convert prefix and hostname to upper case for compact QR codes
842c4a6 is described below
commit 842c4a6f4783b524b98404ef8181dad12e7baa42
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Dec 6 09:12:27 2019 +0100
convert prefix and hostname to upper case for compact QR codes
---
src/main.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
index e8d35c7..aed63a7 100644
--- 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);
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taler-mdb] branch master updated: convert prefix and hostname to upper case for compact QR codes,
gnunet <=