Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
prevent string index out of bounds MultiProtocolURL.getPaths as path maybe a empty string + init path to "" also in init for poison url (to guarantee success for all existing uses of path w/o check for null)
regerf8632ad2921f
diff --git a/source/net/yacy/cora/document/id/MultiProtocolURL.java b/source/net/yacy/cora/document/id/MultiProtocolURL.javaindex 383ede2e7..9844a959b 100644--- a/source/net/yacy/cora/document/id/MultiProtocolURL.java+++ b/source/net/yacy/cora/document/id/MultiProtocolURL.java@@ -142,7 +142,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolUthis.host = null;this.hostAddress = null;this.userInfo = null;- this.path = null;+ this.path = ""; // path is used often without check against null (this init is only used as poison url, but safe is safe, so init to empty string)this.searchpart = null;this.anchor = null;this.contentDomain = null;@@ -866,12 +866,22 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolUreturn fileName.substring(p + 1, q).toLowerCase();}+ /**+ * Get the path (including filename)+ * Path is never null+ * returns may range from empty string, just "/" to a full path+ * @return+ */public String getPath() {return this.path;}+ /**+ * Get path elements (directories) as array+ * @return array with directory names or empty array+ */public String[] getPaths() {- String s = this.path == null ? "" : this.path.charAt(0) == '/' ? this.path.substring(1) : this.path;+ String s = (this.path == null || this.path.length() < 1) ? "" : this.path.charAt(0) == '/' ? this.path.substring(1) : this.path;int p = s.lastIndexOf('/');if (p < 0) return new String[0];s = s.substring(0, p); // the paths do not contain the last part, which is considered as the getFileName() part.