From 2763487730d8fbd88ef98d51a98193f2f89786f7 Mon Sep 17 00:00:00 2001 From: Martin Paljak Date: Sun, 22 Oct 2023 20:17:38 +0300 Subject: [PATCH] Fix #8 - no need to urlencode the url components itself. appendUri constructs a new URI, which will urlencode the payload as needed --- src/main/java/pro/javacard/nfc4pc/NFC4PC.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/pro/javacard/nfc4pc/NFC4PC.java b/src/main/java/pro/javacard/nfc4pc/NFC4PC.java index 4a06fea..7d6361e 100644 --- a/src/main/java/pro/javacard/nfc4pc/NFC4PC.java +++ b/src/main/java/pro/javacard/nfc4pc/NFC4PC.java @@ -52,7 +52,7 @@ public NFC4PC(OptionSet opts, Thread shutdownHook) { // by default there is timeout, unless run with -t 0 if (secs > 0) { - idler = idle.schedule(() ->{ + idler = idle.schedule(() -> { System.err.printf("Timeout, no tap within %d seconds!%n", secs); Runtime.getRuntime().removeShutdownHook(shutdownHook); System.exit(2); @@ -150,7 +150,8 @@ static URI transform(NFCTapData data, OptionSet opts) throws URISyntaxException if (opts.has(OPT_META_URL)) { target = appendUri(opts.valueOf(OPT_META_URL), "uid", uid2str(data.uid())); if (data.url() != null) { - target = appendUri(target, "url", URLEncoder.encode(data.url().toASCIIString(), StandardCharsets.UTF_8)); + // NOTE: appendUri does urlencoding as it constructs a new URI from string components + target = appendUri(target, "url", data.url().toASCIIString()); } } else if (data.url() == null && opts.has(OPT_UID_URL)) { // or UID, if url is empty