incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r900398 - /sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java
Date Mon, 18 Jan 2010 14:09:48 GMT
Author: cziegeler
Date: Mon Jan 18 14:09:48 2010
New Revision: 900398

URL: http://svn.apache.org/viewvc?rev=900398&view=rev
Log:
Parameters should be encoded by standard encoding only.

Modified:
    sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java

Modified: sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java?rev=900398&r1=900397&r2=900398&view=diff
==============================================================================
--- sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java
(original)
+++ sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/impl/DefaultPortalURLFactory.java
Mon Jan 18 14:09:48 2010
@@ -125,7 +125,7 @@
         }
     }
 
-    private boolean appendParameter(final StringBuilder buffer,
+    private boolean appendSpecialParameter(final StringBuilder buffer,
                                     final String name,
                                     final String value,
                                     final boolean firstParam) {
@@ -140,6 +140,26 @@
         return false;
     }
 
+    private boolean appendParameter(final StringBuilder buffer,
+            final String name,
+            final String value,
+            final boolean firstParam) {
+        if ( firstParam ) {
+            buffer.append('?');
+        } else {
+            buffer.append('&');
+        }
+        buffer.append(name);
+        buffer.append('=');
+        try {
+            buffer.append(URLEncoder.encode(value, "UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            // this should never happen, but we gracefully append just the value
+            buffer.append(value);
+        }
+        return false;
+    }
+
     private boolean appendControlParameter(final StringBuilder buffer,
                                            final String name,
                                            final String key,
@@ -213,11 +233,11 @@
 
         // Append the resource window definition, if it exists.
         if (portalURL.getResourceWindow() != null){
-            firstParam = this.appendParameter(buffer, RESOURCE, portalURL.getResourceWindow(),
firstParam);
+            firstParam = this.appendSpecialParameter(buffer, RESOURCE, portalURL.getResourceWindow(),
firstParam);
         }
         // Append the action window definition, if it exists.
         if (portalURL.getActionWindow() != null) {
-            firstParam = this.appendParameter(buffer, ACTION, portalURL.getActionWindow(),
firstParam);
+            firstParam = this.appendSpecialParameter(buffer, ACTION, portalURL.getActionWindow(),
firstParam);
         }
 
         // Append portlet mode definitions.



Mime
View raw message