Skip to content

Commit

Permalink
Merge pull request #208 from ipfs-shipyard/fix/incorrect-encoding
Browse files Browse the repository at this point in the history
use correct version of method to URL encode string
  • Loading branch information
kevodwyer authored Jan 26, 2023
2 parents 49bd34a + 61f7a9b commit 89b069b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/io/ipfs/api/IPFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public List<MerkleNode> add(List<NamedStreamable> files, boolean wrap, boolean h
m.addSubtree(Paths.get(""), file);
} else
m.addFilePart("file", Paths.get(""), file);
};
}
String res = m.finish();
return JSONParser.parseStream(res).stream()
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
Expand All @@ -145,7 +145,7 @@ public List<MerkleNode> add(List<NamedStreamable> files, AddArgs args) throws IO
m.addSubtree(Paths.get(""), file);
} else
m.addFilePart("file", Paths.get(""), file);
};
}
String res = m.finish();
return JSONParser.parseStream(res).stream()
.map(x -> MerkleNode.fromJSON((Map<String, Object>) x))
Expand Down Expand Up @@ -420,10 +420,8 @@ public Object peers(String topic) throws IOException {

/**
*
* @param topic
* @param topic topic to publish to
* @param data url encoded data to be published
* @return
* @throws IOException
*/
public void pub(String topic, String data) {
String encodedTopic = Multibase.encode(Multibase.Base.Base64Url, topic.getBytes());
Expand Down Expand Up @@ -471,7 +469,7 @@ public List<Map> codecs(boolean numeric, boolean supported) throws IOException
}

public Map format(Cid hash, Optional<String> f, Optional<String> v, Optional<String> mc, Optional<String> b) throws IOException {
String fArg = f.isPresent() ? "&f=" + URLEncoder.encode(f.get()) : "";
String fArg = f.isPresent() ? "&f=" + URLEncoder.encode(f.get(), "UTF-8") : "";
String vArg = v.isPresent() ? "&v=" + v.get() : "";
String mcArg = mc.isPresent() ? "&mc=" + mc.get() : "";
String bArg = b.isPresent() ? "&b=" + b.get() : "";
Expand Down

0 comments on commit 89b069b

Please sign in to comment.