[ 
https://issues.apache.org/jira/browse/WICKET-7024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17893444#comment-17893444
 ] 

ASF GitHub Bot commented on WICKET-7024:
----------------------------------------

martin-g commented on code in PR #1021:
URL: https://github.com/apache/wicket/pull/1021#discussion_r1819015012


##########
wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java:
##########
@@ -396,4 +405,67 @@ void noRequestCycle()
                assertEquals(variations[1], 
resource.getResourceStream().getVariation());
        }
 
+       @Test
+       public void getResouceWithNoStyle()
+       {
+               tester.executeUrl(
+                       
"wicket/resource/org.apache.wicket.core.request.resource.PackageResourceReferenceTest/a.css");
+
+               assertThat(tester.getLastResponseAsString(), 
not(containsString("color")));
+       }
+
+       @Test
+       public void getStyleFromSession()
+       {
+               tester.getSession().setStyle("blue");
+               tester.executeUrl(
+                       
"wicket/resource/org.apache.wicket.core.request.resource.PackageResourceReferenceTest/a.css");
+
+               assertThat(tester.getLastResponseAsString(), 
containsString("blue"));
+       }
+
+       @Test
+       public void decodeStyleFromUrl()
+       {
+               tester.getSession().setStyle("blue");
+               tester.executeUrl(
+                       
"wicket/resource/org.apache.wicket.core.request.resource.PackageResourceReferenceTest/a.css?-orange");
+
+               assertThat(tester.getLastResponseAsString(), 
containsString("orange"));

Review Comment:
   Also assert that there is no `blue`





> Wrong static resource urls when their generation is triggered by <wicket:link>
> ------------------------------------------------------------------------------
>
>                 Key: WICKET-7024
>                 URL: https://issues.apache.org/jira/browse/WICKET-7024
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 9.12.0
>            Reporter: Martin Tzvetanov Grigorov
>            Priority: Major
>         Attachments: wicket-link-leak.tgz
>
>
> If an application uses <wicket:link> to generate a url for a static resource, 
> e.g.
> {code:java}
> <html xmlns="http://www.w3.org/1999/xhtml"; 
> xmlns:wicket="http://wicket.apache.org/";>
> <head>
> <wicket:head>
>   <wicket:link>
>     <link rel="stylesheet" type="text/css" href="css/test2.css"  />
>   </wicket:link>
> </wicket:head>
> </head>
> ...  {code}
> then during the page render time it will use
> {code:java}
> CharSequence url = getRequestCycle().urlFor(handler); {code}
> and 
> [https://github.com/apache/wicket/blob/bc70f127ff74f154890a35be906b55db5bdc8683/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java#L117-L128]
>  will use the current page's url and try to parse locale/style/variation from 
> it and embed it in the static resource url.
> The problem is that it uses the pageId/renderCount/behaviorId and component 
> path instead.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to