diff --git a/apps/addressbook/java/src/net/i2p/router/naming/BlockfileNamingService.java b/apps/addressbook/java/src/net/i2p/router/naming/BlockfileNamingService.java index d72a23a8b2..2c3f8720c4 100644 --- a/apps/addressbook/java/src/net/i2p/router/naming/BlockfileNamingService.java +++ b/apps/addressbook/java/src/net/i2p/router/naming/BlockfileNamingService.java @@ -797,7 +797,7 @@ private Destination lookup2(String hostname, Properties lookupOptions, Propertie if (d != null) return d; // Base32 failed? - if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.toLowerCase(Locale.US).endsWith(".b32.i2p")) + if (hostname.length() >= BASE32_HASH_LENGTH + 8 && hostname.toLowerCase(Locale.US).endsWith(".b32.i2p")) return null; } @@ -848,7 +848,7 @@ private Destination lookup2(String hostname, Properties lookupOptions, Propertie */ private List lookupAll2(String hostname, Properties lookupOptions, List storedOptions) { // only use cache for b32 - if (hostname.length() == BASE32_HASH_LENGTH + 8 && hostname.toLowerCase(Locale.US).endsWith(".b32.i2p")) { + if (hostname.length() >= BASE32_HASH_LENGTH + 8 && hostname.toLowerCase(Locale.US).endsWith(".b32.i2p")) { Destination d = super.lookup(hostname, null, null); if (d != null) { if (storedOptions != null) diff --git a/core/java/src/net/i2p/util/ConvertToHash.java b/core/java/src/net/i2p/util/ConvertToHash.java index 2cb2896a4f..5fd460d726 100644 --- a/core/java/src/net/i2p/util/ConvertToHash.java +++ b/core/java/src/net/i2p/util/ConvertToHash.java @@ -33,9 +33,20 @@ public static Hash getHash(String peer) { if (peer == null) return null; String peerLC = peer.toLowerCase(Locale.US); + if (peerLC.startsWith("http://")) { + peer = peer.substring(7); + peerLC = peerLC.substring(7); + } else if (peerLC.startsWith("https://")) { + peer = peer.substring(8); + peerLC = peerLC.substring(8); + } + if (peer.endsWith("/")) { + peer = peer.substring(0, peer.length() - 1); + peerLC = peerLC.substring(0, peerLC.length() - 1); + } if (peerLC.endsWith(".i2p.alt")) { peer = peer.substring(0, peer.length() - 4); - peerLC = peerLC.substring(0, peer.length() - 4); + peerLC = peerLC.substring(0, peerLC.length() - 4); } // b64 hash if (peer.length() == 44 && !peerLC.endsWith(".i2p")) { diff --git a/router/java/src/net/i2p/router/client/LookupDestJob.java b/router/java/src/net/i2p/router/client/LookupDestJob.java index 2bb8c1de8c..22321c7af5 100644 --- a/router/java/src/net/i2p/router/client/LookupDestJob.java +++ b/router/java/src/net/i2p/router/client/LookupDestJob.java @@ -126,6 +126,9 @@ public LookupDestJob(RouterContext context, ClientConnectionRunner runner, // h and name both null, runJob will fail immediately } } + } else { + // base32 decode fail + name = null; } } }