Wow. Slow down. I already fixed VELTOOLS-146. You need to svn
update your code.
On Thu, Jul 28, 2011 at 10:00 AM, Christopher Schultz
<
chris@...> wrote:
> All,
>
> On 7/28/2011 12:48 PM, Christopher Schultz wrote:
>> I think the solution is to modify this so that
>> generic.LinkTool.absolute() /does/ use the URI class to parse the URI
>> and separate-out the query string, etc. and then set them on the copied
>> LinkTool's instance.
>
> Okay, this works, but I'm not sure if it's the best solution, or if it's
> even a complete solution. StrutsLinkTool calls LinkTool.absolute(), but
> the path is actually a relative path, so maybe calling
> LinkTool.relative() is a better thing to do. In that case, the fix
> should probably be different.
>
> Quick diff for generic.LinkTool:
>
>
> Index: src/main/java/org/apache/velocity/tools/generic/LinkTool.java
> ===================================================================
> --- src/main/java/org/apache/velocity/tools/generic/LinkTool.java
> (revision 1151249)
> +++ src/main/java/org/apache/velocity/tools/generic/LinkTool.java
> (working copy)
> @@ -1357,6 +1357,7 @@
> {
> return null;
> }
> +
> copy.setScheme(uri.getScheme());
> copy.setUserInfo(uri.getUserInfo());
> copy.setHost(uri.getHost());
> @@ -1378,8 +1379,30 @@
> }
> return copy;
> }
> - else if (!pth.startsWith("/"))
> + else if (pth.startsWith("/"))
> {
> + // This is a relative path, not absolute.
> + // That's okay -- parse the URI anyway but don't process
> + // the host, scheme, port, user, etc.
> + URI uri = toURI(pth);
> +
> + pth = uri.getPath();
> + if (pth.equals("/") || pth.length() == 0)
> + {
> + pth = null;
> + }
> + copy.setPath(pth);
> + if (uri.getQuery() != null)
> + {
> + copy.setQuery(uri.getQuery());
> + }
> + if (uri.getFragment() != null)
> + {
> + copy.setFragment(uri.getFragment());
> + }
> + }
> + else
> + {
> // paths that don't start with '/'
> // are considered relative to the current directory
> pth = combinePath(getDirectory(), pth);
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
user-unsubscribe@...
For additional commands, e-mail:
user-help@...