roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r483279 - /incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java
Date Wed, 06 Dec 2006 22:58:55 GMT
Author: agilliland
Date: Wed Dec  6 14:58:55 2006
New Revision: 483279

URL: http://svn.apache.org/viewvc?view=rev&rev=483279
Log:
when forming tagging urls we want to encode each tag independently and join them with a '+'
rather than joining them first and encoding the whole string.  the latter causes the '+' chars
to become %2B which breaks the urls.


Modified:
    incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java

Modified: incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java?view=diff&rev=483279&r1=483278&r2=483279
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/util/URLUtilities.java Wed Dec  6 14:58:55
2006
@@ -181,7 +181,7 @@
             pathinfo.append("date/").append(dateString);  
         
         } else if(tags != null && tags.size() > 0) {
-            pathinfo.append("tags/").append(encode(Utilities.stringArrayToString((String[])tags.toArray(),
"+")));
+            pathinfo.append("tags/").append(getEncodedTagsString(tags));
         } else {
             if(dateString != null) params.put("date", dateString);
             if(cat != null) params.put("cat", encode(cat));
@@ -228,7 +228,7 @@
                 params.put("cat", encode(category));
             }
             if(tags != null && tags.size() > 0) {
-                params.put("tags",encode(Utilities.stringArrayToString((String[])tags.toArray(),
"+")));
+                params.put("tags", getEncodedTagsString(tags));
             }
             if(pageNum > 0) {
                 params.put("page", Integer.toString(pageNum));
@@ -268,7 +268,7 @@
             params.put("cat", encode(category));
         }
         if(tags != null && tags.size() > 0) {
-          params.put("tags",encode(Utilities.stringArrayToString((String[])tags.toArray(),
"+")));
+          params.put("tags", getEncodedTagsString(tags));
         }
         if(excerpts) {
             params.put("excerpts", "true");
@@ -546,4 +546,24 @@
         return decodedStr;
     }
     
+    
+    public static final String getEncodedTagsString(List tags) {
+        StringBuffer tagsString = new StringBuffer();
+        if(tags != null && tags.size() > 0) {
+            String tag = null;
+            Iterator tagsIT = tags.iterator();
+            
+            // do first tag
+            tag = (String) tagsIT.next();
+            tagsString.append(encode(tag));
+            
+            // do rest of tags, joining them with a '+'
+            while(tagsIT.hasNext()) {
+                tag = (String) tagsIT.next();
+                tagsString.append("+");
+                tagsString.append(encode(tag));
+            }
+        }
+        return tagsString.toString();
+    }
 }



Mime
View raw message