Hi!

I'm desperately trying to get a few static image files auto-linked (using <wicket:link> in my markup) to a parent-relative path. It works fine while using .. but I can't figure out how to get the correct src-URLs using any of the workarounds I could find that should appease Wicket so it stops logging the warning:

--->
Your path looks like: ../../images/system/icons/cancel.png
For security reasons moving up '../' is disabled by default. Please see
IResourceSettings.getParentFolderPlaceholder() and PackageResourceGuard for more details
<---

I tried many ways to work around that problem but nothing succeeds in automatically linking the markup, I always end up with the unchanged URL. I would be glad if someone could show me what I do wrong or could even provide me with a small working example (all I could find were one-line examples that don't work for me).

Furthermore, I'm unsure what workaround I should use. The cleanest way would possibly be number 3 listed below. Anyway, all except number 2 break links when viewing the templates without a running Wicket application. Also, I don't really get the difference that workaround 1 makes from what I read. How does it help security if I'm just replacing .. by some arbitrary String like "$up$"?

The application is built using Wicket 1.4.15, Maven and Jetty. It has two different frontends which led to a package structure like:

com
  company
     project
        wicket
           frontend1
              pages
           frontend2
              pages

Markup is stored directly in frontend1.pages and frontend2.pages. The image files have recently been moved from frontend2.pages to com.company.project.wicket so now I have to get two package levels higher. Markup is currently in src/main/java while images are in src/main/resources which shouldn't matter since they are copied to one directory on build/execution.

I would like to show what I tried so far without any luck, so please excuse me if this gets a bit longer:



Workaround 1: Setting the placeholder to $up$ in Application.init()

Code:
getResourceSettings().setParentFolderPlaceholder("$up$");

Markup:
<img src="$up$/$up$/images/system/icons/cancel.png" alt="Cancel" />

Result in a browser:
<img src="$up$/$up$/images/system/icons/cancel.png" alt="Cancel" />



Workaround 2: Mounting a shared resource

I created an empty class CommonResources in com.company.project.wicket so the shared resource key returns com.company.project.wicket.CommonResources/images/system/icons/cancel.png

Code:
mountSharedResource("images/system/icons/cancel.png", new ResourceReference(CommonResources.class, "images/system/icons/cancel.png").getSharedResourceKey());

Markup:
<img src="images/system/icons/cancel.png" alt="Cancel" />

Result: (404)
<img src="images/system/icons/cancel.png" alt="Cancel" />



Workaround 3: Trying to move the icons to a resource directory below the context path (WAR root level)

I called the folder "resourcesearch" because "resources" is already handled by Wicket.

Code: (either one of these two lines)
getResourceSettings().addResourceFolder("resourcesearch");
getResourceSettings().addResourceFolder(getServletContext().getRealPath("/resourcesearch"));

Markup: (also tried without the root slash)
<img src="/resourcesearch/images/system/icons/cancel.png" alt="Cancel" />

Result: (wrong path, it's actually deployed to /ProjectName-Version/)
<img src="/resourcesearch/images/system/icons/cancel.png" alt="Cancel" />


Thanks,
Daniel

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

Reply via email to