Thanks Massimo.

On 11.12.2011 18:47, [email protected] wrote:
> Author: mlusetti
> Date: Sun Dec 11 17:47:16 2011
> New Revision: 1213031
>
> URL: http://svn.apache.org/viewvc?rev=1213031&view=rev
> Log:
> TAP5-1768 - @ActivationRequestParameter does not encode to be URL friendly 
> (merge from trunk)
>
> Modified:
>     tapestry/tapestry5/branches/5.3/   (props changed)
>     
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ActivationRequestParameterWorker.java
>     
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java
>    (props changed)
>     
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/app1/ActivationRequestParameterDemo.tml
>     
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ActivationRequestParameterTests.groovy
>     
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ActivationRequestParameterDemo.java
>
> Propchange: tapestry/tapestry5/branches/5.3/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Sun Dec 11 17:47:16 2011
> @@ -2,4 +2,4 @@
>  /tapestry/tapestry5/branches/hlship-5.0-perf:726734-728728
>  /tapestry/tapestry5/tags/releases/5.0.17:719745
>  /tapestry/tapestry5/tags/releases/hlship-5.0-perf:726733
> -/tapestry/tapestry5/trunk:1211947-1212270
> +/tapestry/tapestry5/trunk:1211947-1212379
>
> Modified: 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ActivationRequestParameterWorker.java
> URL: 
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ActivationRequestParameterWorker.java?rev=1213031&r1=1213030&r2=1213031&view=diff
> ==============================================================================
> --- 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ActivationRequestParameterWorker.java
>  (original)
> +++ 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ActivationRequestParameterWorker.java
>  Sun Dec 11 17:47:16 2011
> @@ -28,6 +28,7 @@ import org.apache.tapestry5.runtime.Comp
>  import org.apache.tapestry5.runtime.ComponentEvent;
>  import org.apache.tapestry5.services.ComponentEventHandler;
>  import org.apache.tapestry5.services.Request;
> +import org.apache.tapestry5.services.URLEncoder;
>  import org.apache.tapestry5.services.ValueEncoderSource;
>  import 
> org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
>  import org.apache.tapestry5.services.transform.TransformationSupport;
> @@ -49,12 +50,15 @@ public class ActivationRequestParameterW
>  
>      private final ValueEncoderSource valueEncoderSource;
>  
> +    private final URLEncoder urlEncoder;
> +
>      public ActivationRequestParameterWorker(Request request, 
> ComponentClassCache classCache,
> -                                            ValueEncoderSource 
> valueEncoderSource)
> +                                            ValueEncoderSource 
> valueEncoderSource, URLEncoder urlEncoder)
>      {
>          this.request = request;
>          this.classCache = classCache;
>          this.valueEncoderSource = valueEncoderSource;
> +        this.urlEncoder = urlEncoder;
>      }
>  
>      public void transform(PlasticClass plasticClass, TransformationSupport 
> support, MutableComponentModel model)
> @@ -82,9 +86,9 @@ public class ActivationRequestParameterW
>  
>          String fieldName = String.format("%s.%s", 
> field.getPlasticClass().getClassName(), field.getName());
>  
> -        setValueFromInitializeEventHandler(support, fieldName, handle, 
> parameterName, encoder);
> +        setValueFromInitializeEventHandler(support, fieldName, handle, 
> parameterName, encoder, urlEncoder);
>  
> -        decorateLinks(support, fieldName, handle, parameterName, encoder);
> +        decorateLinks(support, fieldName, handle, parameterName, encoder, 
> urlEncoder);
>  
>          preallocateName(support, parameterName);
>      }
> @@ -109,7 +113,7 @@ public class ActivationRequestParameterW
>  
>      @SuppressWarnings("all")
>      private void setValueFromInitializeEventHandler(TransformationSupport 
> support, String fieldName, final FieldHandle handle,
> -                                                    final String 
> parameterName, final ValueEncoder encoder)
> +                                                    final String 
> parameterName, final ValueEncoder encoder, final URLEncoder urlEncoder)
>      {
>          ComponentEventHandler handler = new ComponentEventHandler()
>          {
> @@ -120,6 +124,9 @@ public class ActivationRequestParameterW
>                  if (clientValue == null)
>                      return;
>  
> +                // TAP5-1768: unescape encoded value
> +                clientValue = urlEncoder.decode(clientValue);
> +
>                  Object value = encoder.toValue(clientValue);
>  
>                  handle.set(instance, value);
> @@ -133,7 +140,7 @@ public class ActivationRequestParameterW
>  
>      @SuppressWarnings("all")
>      private static void decorateLinks(TransformationSupport support, String 
> fieldName, final FieldHandle handle,
> -                                      final String parameterName, final 
> ValueEncoder encoder)
> +                                      final String parameterName, final 
> ValueEncoder encoder, final URLEncoder urlEncoder)
>      {
>          ComponentEventHandler handler = new ComponentEventHandler()
>          {
> @@ -150,6 +157,9 @@ public class ActivationRequestParameterW
>  
>                  String clientValue = encoder.toClient(value);
>  
> +                // TAP5-1768: escape special characters
> +                clientValue = urlEncoder.encode(clientValue);
> +
>                  link.addParameter(parameterName, clientValue);
>              }
>          };
>
> Propchange: 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Sun Dec 11 17:47:16 2011
> @@ -1 +1 @@
> -/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java:1211947-1212270
> +/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java:1211947-1212379
>
> Modified: 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/app1/ActivationRequestParameterDemo.tml
> URL: 
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/test/app1/ActivationRequestParameterDemo.tml?rev=1213031&r1=1213030&r2=1213031&view=diff
> ==============================================================================
> --- 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/app1/ActivationRequestParameterDemo.tml
>  (original)
> +++ 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/app1/ActivationRequestParameterDemo.tml
>  Sun Dec 11 17:47:16 2011
> @@ -21,6 +21,9 @@
>        <t:actionlink t:id="setMessage">set message</t:actionlink>
>      </li>
>      <li>
> +      <t:actionlink t:id="setSpecialMessage">set special 
> message</t:actionlink>
> +    </li>
> +    <li>
>        <t:actionlink t:id="reset">reset</t:actionlink>
>      </li>
>    </ul>
>
> Modified: 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ActivationRequestParameterTests.groovy
> URL: 
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ActivationRequestParameterTests.groovy?rev=1213031&r1=1213030&r2=1213031&view=diff
> ==============================================================================
> --- 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ActivationRequestParameterTests.groovy
>  (original)
> +++ 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app1/ActivationRequestParameterTests.groovy
>  Sun Dec 11 17:47:16 2011
> @@ -14,9 +14,9 @@
>  
>  package org.apache.tapestry5.integration.app1;
>  
> -import org.apache.tapestry5.corelib.components.Submit;
> -import org.apache.tapestry5.integration.TapestryCoreTestCase 
> -import org.testng.annotations.Test 
> +
> +import org.apache.tapestry5.integration.TapestryCoreTestCase
> +import org.testng.annotations.Test
>  
>  class ActivationRequestParameterTests extends TapestryCoreTestCase
>  {
> @@ -39,7 +39,16 @@ class ActivationRequestParameterTests ex
>          
>          assertText "click-count", "1"
>          assertText "click-count-set", "true"
> -        assertText "message", "Link clicked!"        
> +        assertText "message", "Link clicked!"
> +    }
> +
> +    @Test
> +    void special_chars() {
> +        openLinks "ActivationRequestParameter Annotation Demo"
> +
> +        clickAndWait "link=set special message"
> +
> +        assertText "message", "!#\$&'()*+,/:;=?@[]"
>      }
>      
>      @Test
>
> Modified: 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ActivationRequestParameterDemo.java
> URL: 
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ActivationRequestParameterDemo.java?rev=1213031&r1=1213030&r2=1213031&view=diff
> ==============================================================================
> --- 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ActivationRequestParameterDemo.java
>  (original)
> +++ 
> tapestry/tapestry5/branches/5.3/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ActivationRequestParameterDemo.java
>  Sun Dec 11 17:47:16 2011
> @@ -56,6 +56,11 @@ public class ActivationRequestParameterD
>          message = "Link clicked!";
>      }
>  
> +    void onActionFromSetSpecialMessage()
> +    {
> +        message = "!#$&'()*+,/:;=?@[]";
> +    }
> +
>      void onActionFromReset()
>      {
>          clickCount = null;
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to