Author: low012
Date: 2008-01-23 00:59:15 +0100 (Wed, 23 Jan 2008)
New Revision: 4373

Modified:
   trunk/htroot/Bookmarks.java
Log:
*) heading, trailing and double commas are removed since they are unnecessary
*) trailing and double slashs in paths are removed, they are not only ugly, but 
also caused infinite loops

Modified: trunk/htroot/Bookmarks.java
===================================================================
--- trunk/htroot/Bookmarks.java 2008-01-22 23:14:57 UTC (rev 4372)
+++ trunk/htroot/Bookmarks.java 2008-01-22 23:59:15 UTC (rev 4373)
@@ -6,8 +6,11 @@
 // Frankfurt, Germany, 2004
 //
 // This File is contributed by Alexander Schier
-// last change: 26.12.2005
 //
+// $LastChangedDate: 2008-01-22 12:51:43 +0100 (Di, 22 Jan 2008) $
+// $LastChangedRevision: 4352 $
+// $LastChangedBy: orbiter $
+//
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 // the Free Software Foundation; either version 2 of the License, or
@@ -154,6 +157,28 @@
                        if(tagsString.equals("")){
                                tagsString="unsorted"; //default tag
                        }
+                        
+                        // get rid of heading, trailing and double commas 
since they are useless
+                        while (tagsString.startsWith(",")) {
+                            tagsString = tagsString.substring(1);
+                        }
+                        while (tagsString.endsWith(",")) {
+                            tagsString = 
tagsString.substring(0,tagsString.length() -1);
+                        }
+                        while(tagsString.contains(",,")){
+                            tagsString = tagsString.replaceAll(",,", ",");
+                        }
+                        // get rid of double and trailing slashes
+                        while(tagsString.endsWith("/")){
+                            tagsString = tagsString.substring(0, 
tagsString.length() -1);
+                        }
+                        while(tagsString.contains("/,")){
+                            tagsString = tagsString.replaceAll("/,", ",");
+                        }
+                        while(tagsString.contains("//")){
+                            tagsString = tagsString.replaceAll("//", "/");
+                        }
+                        
                        Set 
tags=listManager.string2set(tagsString.replaceAll(",\\s+", ",")); // space 
characters following a comma are removed
         
                        bookmarksDB.Bookmark bookmark = 
switchboard.bookmarksDB.createBookmark(url, username);
@@ -360,7 +385,16 @@
                while(it.hasNext()){
                        tag=(Tag) it.next();
                        if (tag.getFriendlyName().startsWith("/")) {
-                               path = tag.getFriendlyName();           
+                               path = tag.getFriendlyName();
+                        
+                        // eliminate trailing and double slashes
+                        while(path.endsWith("/")){
+                            path = path.substring(0, path.length() -1);
+                        }
+                        while(path.contains("//")){
+                            path = path.replaceAll("//", "/");
+                        }
+                        
                                while(path.length() > 0){
                                        folders.add(path);
                                        path = path.replaceAll("(/.[^/]*$)", 
"");

_______________________________________________
YaCy-svn mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/yacy-svn

Antwort per Email an