You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andreas Kappler <an...@jato-consulting.de> on 2012/12/03 16:06:20 UTC

UrlResourceReference escapes too much?

Hi,

I am trying to render a reference to a Javascript library which is 
stored somewhere in my webapp directory using UrlResourceReference:

public void renderHead(IHeaderResponse response) {
         super.renderHead(response);
         response.render(JavaScriptHeaderItem.forReference(new 
UrlResourceReference(Url.parse("public/scripts/jquery-ui-1.8.6.custom.min.js")) 
.setContextRelative(true)));
}

This does not work, because our wicket servlet is using a prefix 
("nui"), and thus the URL to the resource (corrently) contains ".." but 
this is escaped for some reason to "::".

So the URL generated by the ResourceReference is e.g. 
"http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js" 
leading to a 404. The correct URL would be 
"http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js" 
As far as I can see, ParentPathReferenceRewriter does the escaping.

Am I using the API not correctly? Thanks for your help!

Best Regards,
Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: UrlResourceReference escapes too much?

Posted by Andreas Kappler <an...@jato-consulting.de>.
I created an issue for this: WICKET-4907 
<https://issues.apache.org/jira/browse/WICKET-4907>

Best Regards,
Andreas

Am 03.12.2012 16:21, schrieb Martin Grigorov:
> I'm not sure. I have to debug it to be able to say what happens.
>
>
> On Mon, Dec 3, 2012 at 4:16 PM, Andreas Kappler <
> andreas.kappler@jato-consulting.de> wrote:
>
>> Hi Martin,
>>
>> thanks for your quick reply, it does indeed work with forUrl but what I
>> didn't mention before is that I am using a ResourceReference because I want
>> to declare a dependency using ResourceReference#**getDependencies. Is
>> there a way to do this?
>>
>> Best Regards,
>> Andreas
>>
>> Am 03.12.2012 16:10, schrieb Martin Grigorov:
>>
>>> Hi,
>>>
>>> Try with org.apache.wicket.markup.head.**JavaScriptHeaderItem#forUrl()
>>> This method cares about context relative urls.
>>>
>>>
>>> On Mon, Dec 3, 2012 at 4:06 PM, Andreas Kappler <
>>> andreas.kappler@jato-**consulting.de <an...@jato-consulting.de>>
>>> wrote:
>>>
>>>   Hi,
>>>> I am trying to render a reference to a Javascript library which is stored
>>>> somewhere in my webapp directory using UrlResourceReference:
>>>>
>>>> public void renderHead(IHeaderResponse response) {
>>>>           super.renderHead(response);
>>>>           response.render(****JavaScriptHeaderItem.****forReference(new
>>>> UrlResourceReference(Url.****parse("public/scripts/jquery-***
>>>> *ui-1.8.6.custom.min.js"))
>>>>
>>>> .setContextRelative(true)));
>>>> }
>>>>
>>>> This does not work, because our wicket servlet is using a prefix ("nui"),
>>>> and thus the URL to the resource (corrently) contains ".." but this is
>>>> escaped for some reason to "::".
>>>>
>>>> So the URL generated by the ResourceReference is e.g. "
>>>> http://localhost:8080/app/****nui/::/public/scripts/jquery-****<http://localhost:8080/app/**nui/::/public/scripts/jquery-**>
>>>> ui-1.8.6.custom.min.js<http://**localhost:8080/app/nui/::/**
>>>> public/scripts/jquery-ui-1.8.**6.custom.min.js<http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js>
>>>>> "
>>>> leading to a 404. The correct URL would be "http://localhost:8080/app/**
>>>> nui/../public/scripts/jquery-****ui-1.8.6.custom.min.js<http:/**
>>>> /localhost:8080/app/nui/../**public/scripts/jquery-ui-1.8.**
>>>> 6.custom.min.js<http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js>
>>>>> "
>>>> As far as I can see, ParentPathReferenceRewriter does the escaping.
>>>>
>>>> Am I using the API not correctly? Thanks for your help!
>>>>
>>>> Best Regards,
>>>> Andreas
>>>>
>>>> ------------------------------****----------------------------**
>>>> --**---------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.org<http://apache.org>
>>>> <us...@wicket.apache.org>
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>


Re: UrlResourceReference escapes too much?

Posted by Martin Grigorov <mg...@apache.org>.
I'm not sure. I have to debug it to be able to say what happens.


On Mon, Dec 3, 2012 at 4:16 PM, Andreas Kappler <
andreas.kappler@jato-consulting.de> wrote:

> Hi Martin,
>
> thanks for your quick reply, it does indeed work with forUrl but what I
> didn't mention before is that I am using a ResourceReference because I want
> to declare a dependency using ResourceReference#**getDependencies. Is
> there a way to do this?
>
> Best Regards,
> Andreas
>
> Am 03.12.2012 16:10, schrieb Martin Grigorov:
>
>> Hi,
>>
>> Try with org.apache.wicket.markup.head.**JavaScriptHeaderItem#forUrl()
>> This method cares about context relative urls.
>>
>>
>> On Mon, Dec 3, 2012 at 4:06 PM, Andreas Kappler <
>> andreas.kappler@jato-**consulting.de <an...@jato-consulting.de>>
>> wrote:
>>
>>  Hi,
>>>
>>> I am trying to render a reference to a Javascript library which is stored
>>> somewhere in my webapp directory using UrlResourceReference:
>>>
>>> public void renderHead(IHeaderResponse response) {
>>>          super.renderHead(response);
>>>          response.render(****JavaScriptHeaderItem.****forReference(new
>>> UrlResourceReference(Url.****parse("public/scripts/jquery-***
>>> *ui-1.8.6.custom.min.js"))
>>>
>>> .setContextRelative(true)));
>>> }
>>>
>>> This does not work, because our wicket servlet is using a prefix ("nui"),
>>> and thus the URL to the resource (corrently) contains ".." but this is
>>> escaped for some reason to "::".
>>>
>>> So the URL generated by the ResourceReference is e.g. "
>>> http://localhost:8080/app/****nui/::/public/scripts/jquery-****<http://localhost:8080/app/**nui/::/public/scripts/jquery-**>
>>> ui-1.8.6.custom.min.js<http://**localhost:8080/app/nui/::/**
>>> public/scripts/jquery-ui-1.8.**6.custom.min.js<http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js>
>>> >"
>>> leading to a 404. The correct URL would be "http://localhost:8080/app/**
>>> nui/../public/scripts/jquery-****ui-1.8.6.custom.min.js<http:/**
>>> /localhost:8080/app/nui/../**public/scripts/jquery-ui-1.8.**
>>> 6.custom.min.js<http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js>
>>> >"
>>>
>>> As far as I can see, ParentPathReferenceRewriter does the escaping.
>>>
>>> Am I using the API not correctly? Thanks for your help!
>>>
>>> Best Regards,
>>> Andreas
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.org<http://apache.org>
>>> <us...@wicket.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Re: UrlResourceReference escapes too much?

Posted by Andreas Kappler <an...@jato-consulting.de>.
Hi Martin,

thanks for your quick reply, it does indeed work with forUrl but what I 
didn't mention before is that I am using a ResourceReference because I 
want to declare a dependency using ResourceReference#getDependencies. Is 
there a way to do this?

Best Regards,
Andreas

Am 03.12.2012 16:10, schrieb Martin Grigorov:
> Hi,
>
> Try with org.apache.wicket.markup.head.JavaScriptHeaderItem#forUrl()
> This method cares about context relative urls.
>
>
> On Mon, Dec 3, 2012 at 4:06 PM, Andreas Kappler <
> andreas.kappler@jato-consulting.de> wrote:
>
>> Hi,
>>
>> I am trying to render a reference to a Javascript library which is stored
>> somewhere in my webapp directory using UrlResourceReference:
>>
>> public void renderHead(IHeaderResponse response) {
>>          super.renderHead(response);
>>          response.render(**JavaScriptHeaderItem.**forReference(new
>> UrlResourceReference(Url.**parse("public/scripts/jquery-**ui-1.8.6.custom.min.js"))
>> .setContextRelative(true)));
>> }
>>
>> This does not work, because our wicket servlet is using a prefix ("nui"),
>> and thus the URL to the resource (corrently) contains ".." but this is
>> escaped for some reason to "::".
>>
>> So the URL generated by the ResourceReference is e.g. "
>> http://localhost:8080/app/**nui/::/public/scripts/jquery-**
>> ui-1.8.6.custom.min.js<http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js>"
>> leading to a 404. The correct URL would be "http://localhost:8080/app/**
>> nui/../public/scripts/jquery-**ui-1.8.6.custom.min.js<http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js>"
>> As far as I can see, ParentPathReferenceRewriter does the escaping.
>>
>> Am I using the API not correctly? Thanks for your help!
>>
>> Best Regards,
>> Andreas
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: UrlResourceReference escapes too much?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Try with org.apache.wicket.markup.head.JavaScriptHeaderItem#forUrl()
This method cares about context relative urls.


On Mon, Dec 3, 2012 at 4:06 PM, Andreas Kappler <
andreas.kappler@jato-consulting.de> wrote:

> Hi,
>
> I am trying to render a reference to a Javascript library which is stored
> somewhere in my webapp directory using UrlResourceReference:
>
> public void renderHead(IHeaderResponse response) {
>         super.renderHead(response);
>         response.render(**JavaScriptHeaderItem.**forReference(new
> UrlResourceReference(Url.**parse("public/scripts/jquery-**ui-1.8.6.custom.min.js"))
> .setContextRelative(true)));
> }
>
> This does not work, because our wicket servlet is using a prefix ("nui"),
> and thus the URL to the resource (corrently) contains ".." but this is
> escaped for some reason to "::".
>
> So the URL generated by the ResourceReference is e.g. "
> http://localhost:8080/app/**nui/::/public/scripts/jquery-**
> ui-1.8.6.custom.min.js<http://localhost:8080/app/nui/::/public/scripts/jquery-ui-1.8.6.custom.min.js>"
> leading to a 404. The correct URL would be "http://localhost:8080/app/**
> nui/../public/scripts/jquery-**ui-1.8.6.custom.min.js<http://localhost:8080/app/nui/../public/scripts/jquery-ui-1.8.6.custom.min.js>"
> As far as I can see, ParentPathReferenceRewriter does the escaping.
>
> Am I using the API not correctly? Thanks for your help!
>
> Best Regards,
> Andreas
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>