Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

bugfix: bookmarks can now handle folder names like /news and /newspaper without getting confused...

apfelmaennchen3dc208fad042
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index 2d63739c8..fa6c44972 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -380,7 +380,7 @@ public class Bookmarks {
private static int recurseFolders(final Iterator<String> it, String root, int count, final boolean next, final String prev){
String fn="";
bookmarksDB.Bookmark bookmark;
-
+
if (next) fn = it.next();
else fn = prev;
@@ -394,7 +394,7 @@ public class Bookmarks {
return count;
}
- if(fn.startsWith(root)){
+ if(fn.startsWith((root.equals("/") ? root : root+"/"))){
prop.put("folderlist_"+count+"_folder", "<li>"+fn.replaceFirst(root+"/*","")+"<ul class=\"folder\">");
count++;
final Iterator<String> bit=sb.bookmarksDB.getBookmarksIterator(fn, isAdmin);
diff --git a/htroot/xml/bookmarks/get_bookmarks.java b/htroot/xml/bookmarks/get_bookmarks.java
index 62a1dbf55..13a9743fe 100644
--- a/htroot/xml/bookmarks/get_bookmarks.java
+++ b/htroot/xml/bookmarks/get_bookmarks.java
@@ -213,7 +213,7 @@ public class get_bookmarks {
return count;
}
- if(fn.startsWith(root)){
+ if(fn.startsWith((root.equals("/") ? root : root+"/"))){
prop.put("display_xbel_"+count+"_elements", "<folder id=\""+bookmarksDB.tagHash(fn)+"\">");
count++;
@@ -226,8 +226,10 @@ public class get_bookmarks {
count = recurseFolders(it, fn, count, true, fn);
}
} else {
- prop.put("display_xbel_"+count+"_elements", "</folder>");
- count++;
+ if (count > 0) {
+ prop.put("display_xbel_"+count+"_elements", "</folder>");
+ count++;
+ }
root = root.replaceAll("(/.[^/]*$)", "");
if(root.equals("")) root = "/";
count = recurseFolders(it, root, count, false, fn);
diff --git a/htroot/xml/bookmarks/xbel/xbel.java b/htroot/xml/bookmarks/xbel/xbel.java
index 3c1f9058b..1256da0bf 100644
--- a/htroot/xml/bookmarks/xbel/xbel.java
+++ b/htroot/xml/bookmarks/xbel/xbel.java
@@ -78,7 +78,7 @@ public class xbel {
return count;
}
- if(fn.startsWith(root)){
+ if(fn.startsWith((root.equals("/") ? root : root+"/"))){
prop.put("xbel_"+count+"_elements", "<folder id=\""+bookmarksDB.tagHash(fn)+"\">");
count++;
@@ -91,8 +91,10 @@ public class xbel {
count = recurseFolders(it, fn, count, true, fn);
}
} else {
- prop.put("xbel_"+count+"_elements", "</folder>");
- count++;
+ if (count > 0) {
+ prop.put("xbel_"+count+"_elements", "</folder>");
+ count++;
+ }
root = root.replaceAll("(/.[^/]*$)", "");
if(root.equals("")) root = "/";
count = recurseFolders(it, root, count, false, fn);
diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.java
index 153788b48..0b02ecc41 100644
--- a/source/de/anomic/data/bookmarksDB.java
+++ b/source/de/anomic/data/bookmarksDB.java
@@ -323,8 +323,8 @@ public class bookmarksDB {
Tag tag;
while(it.hasNext()){
- tag=it.next();
- if (tag.getFriendlyName().startsWith(root)) {
+ tag=it.next();
+ if (tag.getFriendlyName().startsWith((root.equals("/") ? root : root+"/"))) {
path = tag.getFriendlyName();
path = cleanTagsString(path);
while(path.length() > 0 && !path.equals(root)){