You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/02/08 01:05:25 UTC
svn commit: r619692 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/internal/
main/java/org/apache/tapestry/internal/services/ test/app1/
test/java/org/apache/tapestry/integration/
test/java/org/apache/tapestry/integrati...
Author: hlship
Date: Thu Feb 7 16:05:17 2008
New Revision: 619692
URL: http://svn.apache.org/viewvc?rev=619692&view=rev
Log:
TAPESTRY-2054: page activation context with spaces are incorrectly decoded when using forms
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PageContextInForm.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/PageContextInForm.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java?rev=619692&r1=619691&r2=619692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/TapestryInternalUtils.java Thu Feb 7 16:05:17 2008
@@ -538,7 +538,14 @@
private static final String ENCODED_SLASH = "%2F";
private static final Pattern ENCODED_SLASH_PATTERN = Pattern.compile(ENCODED_SLASH, Pattern.CASE_INSENSITIVE);
- static String escapePercentAndSlash(String input)
+ /**
+ * Encodes percent and slash characters in the string for later decoding via
+ * {@link #unescapePercentAndSlash(String)}.
+ *
+ * @param input string to encode
+ * @return modified string
+ */
+ public static String escapePercentAndSlash(String input)
{
return replace(replace(input, PERCENT_PATTERN, ENCODED_PERCENT), SLASH_PATTERN, ENCODED_SLASH);
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java?rev=619692&r1=619691&r2=619692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/LinkFactoryImpl.java Thu Feb 7 16:05:17 2008
@@ -140,7 +140,7 @@
// Now see if the page has an activation context.
- addActivationContextToLink(link, activationContext);
+ addActivationContextToLink(link, activationContext, forForm);
_componentInvocationMap.store(link, invocation);
@@ -150,7 +150,7 @@
return link;
}
- private void addActivationContextToLink(Link link, String[] activationContext)
+ private void addActivationContextToLink(Link link, String[] activationContext, boolean forForm)
{
if (activationContext.length == 0) return;
@@ -160,7 +160,9 @@
{
if (i > 0) builder.append("/");
- builder.append(TapestryInternalUtils.encodeContext(activationContext[i]));
+ builder.append(forForm
+ ? TapestryInternalUtils.escapePercentAndSlash(activationContext[i])
+ : TapestryInternalUtils.encodeContext(activationContext[i]));
}
link.addParameter(InternalConstants.PAGE_CONTEXT_NAME, builder.toString());
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PageContextInForm.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PageContextInForm.tml?rev=619692&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PageContextInForm.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/PageContextInForm.tml Thu Feb 7 16:05:17 2008
@@ -0,0 +1,17 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Page Context in Form</h1>
+
+ <h2>Activation Context</h2>
+ <t:if test="activationContext">
+ <ul>
+ <li t:type="loop" source="activationContext" value="object">${object}</li>
+ </ul>
+ <t:parameter name="else">No activation context.</t:parameter>
+ </t:if>
+
+ <t:form>
+ <input type="submit"/>
+ </t:form>
+
+</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=619692&r1=619691&r2=619692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Feb 7 16:05:17 2008
@@ -774,6 +774,20 @@
}
@Test
+ public void page_context_in_form()
+ {
+ start("Page Context in Form");
+
+ assertTextSeries("//li[%d]", 1, "betty", "wilma", "context with spaces", "context/with/slashes");
+ assertFieldValue("t:ac", "betty/wilma/context with spaces/context%2Fwith%2Fslashes");
+
+ clickAndWait(SUBMIT);
+
+ assertTextSeries("//li[%d]", 1, "betty", "wilma", "context with spaces", "context/with/slashes");
+ assertFieldValue("t:ac", "betty/wilma/context with spaces/context%2Fwith%2Fslashes");
+ }
+
+ @Test
public void client_side_validation()
{
start("Client Validation Demo");
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/PageContextInForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/PageContextInForm.java?rev=619692&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/PageContextInForm.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/PageContextInForm.java Thu Feb 7 16:05:17 2008
@@ -0,0 +1,54 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app1.pages;
+
+public class PageContextInForm
+{
+ private Object[] _activationContext;
+
+ private Object _object;
+
+ void onActivate(Object[] context)
+ {
+ _activationContext = context;
+ }
+
+ Object[] onPassivate()
+ {
+ if (_activationContext != null)
+ {
+ return _activationContext;
+ }
+ else
+ {
+ return new Object[]{"betty", "wilma", "context with spaces", "context/with/slashes"};
+ }
+ }
+
+ public Object[] getActivationContext()
+ {
+ return _activationContext;
+ }
+
+ public Object getObject()
+ {
+ return _object;
+ }
+
+ public void setObject(Object object)
+ {
+ _object = object;
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java?rev=619692&r1=619691&r2=619692&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Start.java Thu Feb 7 16:05:17 2008
@@ -138,6 +138,7 @@
new Item("pagelinkcontext", "PageLink Context Demo", "passing explicit context in a page render link"),
+ new Item("pagecontextinform", "Page Context in Form", "passivate/activate page context in Form"),
new Item("ValidBeanEditorDemo", "Client Validation Demo", "BeanEditor with validation enabled"),
@@ -220,7 +221,6 @@
new Item("RenderPhaseMethodExceptionDemo", "Render Phase Method Exception Demo",
"render phase methods may throw checked exceptions"),
-
new Item("TrackEditor", "Generic Page Class Demo",
"demo use of generics with component classes and, particularily, with property types"));