better check for bad urls in url transmission

pull/1/head
Michael Peter Christen 13 years ago
parent d39463a85c
commit f9fc5cfaba

@ -213,15 +213,16 @@ public class URIMetadataRow implements URIMetadata {
this.comp = null; this.comp = null;
} }
public URIMetadataRow(final Properties prop) { public URIMetadataRow(final Properties prop) throws kelondroException {
// generates an plasmaLURLEntry using the properties from the argument // generates an plasmaLURLEntry using the properties from the argument
// the property names must correspond to the one from toString // the property names must correspond to the one from toString
//System.out.println("DEBUG-ENTRY: prop=" + prop.toString()); //System.out.println("DEBUG-ENTRY: prop=" + prop.toString());
DigestURI url; DigestURI url;
String urls = crypt.simpleDecode(prop.getProperty("url", ""));
try { try {
url = new DigestURI(crypt.simpleDecode(prop.getProperty("url", ""))); url = new DigestURI(urls);
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {
url = null; throw new kelondroException("bad url: " + urls);
} }
String descr = crypt.simpleDecode(prop.getProperty("descr", "")); if (descr == null) descr = ""; 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 = ""; String dc_creator = crypt.simpleDecode(prop.getProperty("author", "")); if (dc_creator == null) dc_creator = "";
@ -285,8 +286,9 @@ public class URIMetadataRow implements URIMetadata {
try { try {
return new URIMetadataRow(MapTools.s2p(propStr.substring(1, propStr.length() - 1))); return new URIMetadataRow(MapTools.s2p(propStr.substring(1, propStr.length() - 1)));
} catch (final kelondroException e) { } catch (final kelondroException e) {
// wrong format // wrong format
return null; Log.logSevere("URIMetadataRow", e.getMessage());
return null;
} }
} }
@ -589,6 +591,7 @@ public class URIMetadataRow implements URIMetadata {
//return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}"; //return "{" + core + ",snippet=" + crypt.simpleEncode(snippet) + "}";
} }
@Override
public Request toBalancerEntry(final String initiatorHash) { public Request toBalancerEntry(final String initiatorHash) {
return new Request( return new Request(
ASCII.getBytes(initiatorHash), ASCII.getBytes(initiatorHash),

Loading…
Cancel
Save