From f9fc5cfabaeeb83d67284e1615802c6f6aeb9133 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 17 Aug 2012 17:17:00 +0200 Subject: [PATCH] better check for bad urls in url transmission --- .../net/yacy/kelondro/data/meta/URIMetadataRow.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java index 7374f4121..07477c67c 100644 --- a/source/net/yacy/kelondro/data/meta/URIMetadataRow.java +++ b/source/net/yacy/kelondro/data/meta/URIMetadataRow.java @@ -213,15 +213,16 @@ public class URIMetadataRow implements URIMetadata { this.comp = null; } - public URIMetadataRow(final Properties prop) { + public URIMetadataRow(final Properties prop) throws kelondroException { // generates an plasmaLURLEntry using the properties from the argument // the property names must correspond to the one from toString //System.out.println("DEBUG-ENTRY: prop=" + prop.toString()); DigestURI url; + String urls = crypt.simpleDecode(prop.getProperty("url", "")); try { - url = new DigestURI(crypt.simpleDecode(prop.getProperty("url", ""))); + url = new DigestURI(urls); } catch (final MalformedURLException e) { - url = null; + throw new kelondroException("bad url: " + urls); } String descr = crypt.simpleDecode(prop.getProperty("descr", "")); if (descr == null) descr = ""; String dc_creator = crypt.simpleDecode(prop.getProperty("author", "")); if (dc_creator == null) dc_creator = ""; @@ -285,8 +286,9 @@ public class URIMetadataRow implements URIMetadata { try { return new URIMetadataRow(MapTools.s2p(propStr.substring(1, propStr.length() - 1))); } catch (final kelondroException e) { - // wrong format - return null; + // wrong format + Log.logSevere("URIMetadataRow", e.getMessage()); + return null; } } @@ -589,6 +591,7 @@ public class URIMetadataRow implements URIMetadata { //return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}"; } + @Override public Request toBalancerEntry(final String initiatorHash) { return new Request( ASCII.getBytes(initiatorHash),