From a8dada6c89c0b1a049986d82310f2d17cf24d6d8 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Wed, 19 Apr 2017 00:20:51 +0200 Subject: [PATCH] Alternative key exchange by providing the public key in the URI (bugfixes) --- .../apps/abit/CreateAddressActivity.java | 26 ++++++++++--------- .../ch/dissem/apps/abit/util/Drawables.java | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/ch/dissem/apps/abit/CreateAddressActivity.java b/app/src/main/java/ch/dissem/apps/abit/CreateAddressActivity.java index 27d344d..6ed8060 100644 --- a/app/src/main/java/ch/dissem/apps/abit/CreateAddressActivity.java +++ b/app/src/main/java/ch/dissem/apps/abit/CreateAddressActivity.java @@ -64,18 +64,20 @@ public class CreateAddressActivity extends AppCompatActivity { String[] parameters = getParameters(uri); for (String parameter : parameters) { Matcher matcher = KEY_VALUE_PATTERN.matcher(parameter); - String key = matcher.group(1).toLowerCase(); - String value = matcher.group(2); - switch (key) { - case "label": - label.setText(value.trim()); - break; - case "action": - subscribe.setChecked(value.trim().equalsIgnoreCase("subscribe")); - break; - case "pubkey": - pubkeyBytes = Base64.decode(value, URL_SAFE); - break; + if (matcher.find()) { + String key = matcher.group(1).toLowerCase(); + String value = matcher.group(2); + switch (key) { + case "label": + label.setText(value.trim()); + break; + case "action": + subscribe.setChecked(value.trim().equalsIgnoreCase("subscribe")); + break; + case "pubkey": + pubkeyBytes = Base64.decode(value, URL_SAFE); + break; + } } } diff --git a/app/src/main/java/ch/dissem/apps/abit/util/Drawables.java b/app/src/main/java/ch/dissem/apps/abit/util/Drawables.java index d577515..dfda9c8 100644 --- a/app/src/main/java/ch/dissem/apps/abit/util/Drawables.java +++ b/app/src/main/java/ch/dissem/apps/abit/util/Drawables.java @@ -43,6 +43,7 @@ import ch.dissem.bitmessage.exception.ApplicationException; import static android.graphics.Color.BLACK; import static android.graphics.Color.WHITE; +import static android.util.Base64.NO_WRAP; import static android.util.Base64.URL_SAFE; /** @@ -85,7 +86,7 @@ public class Drawables { } catch (IOException e) { throw new ApplicationException(e); } - link.append("pubkey=").append(Base64.encodeToString(pubkey.toByteArray(), URL_SAFE)); + link.append("pubkey=").append(Base64.encodeToString(pubkey.toByteArray(), URL_SAFE | NO_WRAP)); } BitMatrix result; try {