Slashes in query/context parameter

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Slashes in query/context parameter

Nathan Quirynen
Hi,

I have a page that needs to accept an url as query or context parameter.

So for example: https://abc.com?redirectUrl=https://def.com/abc123/456

But Tapestry does not accept the slashes (even if I use the %2F notation):

*Input string '[...]' is not valid; the character '/' at position 7 is
not valid.*

How can I achieve what I need with Tapestry?


Nathan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Slashes in query/context parameter

Cezary Biernacki
Tapestry uses its own encoding (with $ used as escape + four hex digits
unicode) for URLs, see org.apache.tapestry5.services.URLEncoder and
 implementation org.apache.tapestry5.internal.services.URLEncoderImpl
<https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/URLEncoderImpl.java>
.

Try https://abc.com/?redirectUrl=https:$002f$002fdef.com$002fabc123$002f456



You can test encodings with this code:

TestPage.java

public class TestPage {

    @ActivationRequestParameter
    @Property
    private String redirectUrl;

    public void onActivate() {
        if (redirectUrl == null) {
            redirectUrl = "http://example.org/page";
        }
    }
}


TestPage.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<body>
<div>
    <t:form>
        <t:textfield value="redirectUrl"/>
        <t:submit/>
    </t:form>
</div>
</body>
</html>



On Tue, Jun 20, 2017 at 6:12 PM, Nathan Quirynen <
[hidden email]> wrote:

> Hi,
>
> I have a page that needs to accept an url as query or context parameter.
>
> So for example: https://abc.com?redirectUrl=https://def.com/abc123/456
>
> But Tapestry does not accept the slashes (even if I use the %2F notation):
>
> *Input string '[...]' is not valid; the character '/' at position 7 is not
> valid.*
>
> How can I achieve what I need with Tapestry?
>
>
> Nathan
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Slashes in query/context parameter

Thiago H. de Paula Figueiredo
In reply to this post by Nathan Quirynen
On Tue, Jun 20, 2017 at 1:12 PM, Nathan Quirynen <
[hidden email]> wrote:

> Hi,
>
> I have a page that needs to accept an url as query or context parameter.
>
> So for example: https://abc.com?redirectUrl=https://def.com/abc123/456
>
> But Tapestry does not accept the slashes (even if I use the %2F notation):
>
> *Input string '[...]' is not valid; the character '/' at position 7 is not
> valid.*
>

How are you getting this query parameter value? I believe
Request.getParameter() should give you the right value without issues.


>
> How can I achieve what I need with Tapestry?
>
>
> Nathan
>
>


--
Thiago
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Slashes in query/context parameter

Nathan Quirynen
Hey,

I was using @ActivationRequestParameter as I need it to be a part of
activation/passivation so it does not get lost when changing language
for example.

Using Request.getParameter() does work, but then I'm not sure how to use
activation/passivation exactly.

But as Cezary said in another reply, I can use URLEncoder in my other
application (which is also a Tapestry application) to create the link
with the url parameter and then use @ActivationRequestParameter.


Op 20/06/2017 om 23:17 schreef Thiago H. de Paula Figueiredo:

> On Tue, Jun 20, 2017 at 1:12 PM, Nathan Quirynen <
> [hidden email]> wrote:
>
>> Hi,
>>
>> I have a page that needs to accept an url as query or context parameter.
>>
>> So for example: https://abc.com?redirectUrl=https://def.com/abc123/456
>>
>> But Tapestry does not accept the slashes (even if I use the %2F notation):
>>
>> *Input string '[...]' is not valid; the character '/' at position 7 is not
>> valid.*
>>
> How are you getting this query parameter value? I believe
> Request.getParameter() should give you the right value without issues.
>
>
>> How can I achieve what I need with Tapestry?
>>
>>
>> Nathan
>>
>>
>


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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Slashes in query/context parameter

Nathan Quirynen
In reply to this post by Cezary Biernacki
Hi Cezary,

Thanks, exactly what I needed.

As I am creating the link with the url parameter in another Tapestry
application I can just use the URLEncoder.encode() method.


Op 20/06/2017 om 21:57 schreef Cezary Biernacki:

> Tapestry uses its own encoding (with $ used as escape + four hex digits
> unicode) for URLs, see org.apache.tapestry5.services.URLEncoder and
>   implementation org.apache.tapestry5.internal.services.URLEncoderImpl
> <https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/URLEncoderImpl.java>
> .
>
> Try https://abc.com/?redirectUrl=https:$002f$002fdef.com$002fabc123$002f456
>
>
>
> You can test encodings with this code:
>
> TestPage.java
>
> public class TestPage {
>
>      @ActivationRequestParameter
>      @Property
>      private String redirectUrl;
>
>      public void onActivate() {
>          if (redirectUrl == null) {
>              redirectUrl = "http://example.org/page";
>          }
>      }
> }
>
>
> TestPage.tml
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
> <body>
> <div>
>      <t:form>
>          <t:textfield value="redirectUrl"/>
>          <t:submit/>
>      </t:form>
> </div>
> </body>
> </html>
>
>
>
> On Tue, Jun 20, 2017 at 6:12 PM, Nathan Quirynen <
> [hidden email]> wrote:
>
>> Hi,
>>
>> I have a page that needs to accept an url as query or context parameter.
>>
>> So for example: https://abc.com?redirectUrl=https://def.com/abc123/456
>>
>> But Tapestry does not accept the slashes (even if I use the %2F notation):
>>
>> *Input string '[...]' is not valid; the character '/' at position 7 is not
>> valid.*
>>
>> How can I achieve what I need with Tapestry?
>>
>>
>> Nathan
>>
>>


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

Loading...