Skip to content

Commit

Permalink
Fix #8 - no need to urlencode the url components itself.
Browse files Browse the repository at this point in the history
appendUri constructs a new URI, which will urlencode the payload as needed
  • Loading branch information
martinpaljak committed Oct 22, 2023
1 parent 2c681ee commit 7179c65
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/pro/javacard/nfc4pc/NFC4PC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7179c65

Please sign in to comment.