Author: mwringe
Date: 2011-10-31 16:30:56 -0400 (Mon, 31 Oct 2011)
New Revision: 7916
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPPortletURL.java
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/WSRPPortletURLTestCase.java
Log:
PBR-207: updating the behaviour of the WSRPPortletURL so that it will handle a doubly
encoded ampersand as a singly encoded ampersand instead of throwing an error. There
appears to be an issue with how the Sun JSF implementation handles url encoding inside an
html attribute. See PBR-207 for more details.
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPPortletURL.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPPortletURL.java 2011-10-31
13:07:43 UTC (rev 7915)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPPortletURL.java 2011-10-31
20:30:56 UTC (rev 7916)
@@ -215,10 +215,16 @@
}
// standardize parameter separators
- if (encodedURL.contains(AMP_AMP))
- {
- throw new IllegalArgumentException(encodedURL + " contains a doubly encoded
&!");
- }
+
+ //NOTE: this is an error here, we should not be getting AMP_AMP, but if makes more
sense for
+ // now to handle the situation right now than to throw an error.
+ // If we reneable this check, make sure to uncomment
testDoublyEncodedAmpersand in WSRPPortletURLTestCase
+ //if (encodedURL.contains(AMP_AMP))
+ //{
+ // throw new IllegalArgumentException(encodedURL + " contains a doubly encoded
&!");
+ //}
+
+ encodedURL = TextTools.replace(encodedURL, AMP_AMP, PARAM_SEPARATOR);
encodedURL = TextTools.replace(encodedURL, ENCODED_AMPERSAND, PARAM_SEPARATOR);
encodedURL = TextTools.replace(encodedURL, AMPERSAND, PARAM_SEPARATOR);
Modified:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/WSRPPortletURLTestCase.java
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/WSRPPortletURLTestCase.java 2011-10-31
13:07:43 UTC (rev 7915)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/WSRPPortletURLTestCase.java 2011-10-31
20:30:56 UTC (rev 7916)
@@ -266,19 +266,20 @@
checkInvalidURL(invalid, message, "foo");
}
- public void testDoublyEncodedAmpersand()
- {
- String expected =
"wsrp_rewrite?wsrp-urlType=render&wsrp-mode=wsrp:help&wsrp-windowState=wsrp:maximized/wsrp_rewrite";
- try
- {
- WSRPPortletURL.create(expected);
- fail("Should have thrown an exception on doubly encoded &!");
- }
- catch (Exception e)
- {
- // expected
- }
- }
+// Disable this test for now as we handle the doubly encoded ampersand.
+// public void testDoublyEncodedAmpersand()
+// {
+// String expected =
"wsrp_rewrite?wsrp-urlType=render&wsrp-mode=wsrp:help&wsrp-windowState=wsrp:maximized/wsrp_rewrite";
+// try
+// {
+// WSRPPortletURL.create(expected);
+// fail("Should have thrown an exception on doubly encoded &!");
+// }
+// catch (Exception e)
+// {
+// // expected
+// }
+// }
/** Relax validation and test that we now accept normally invalid URLs. */
public void testExtraParametersRelaxedValidation()