Revision: 1269
          http://stripes.svn.sourceforge.net/stripes/?rev=1269&view=rev
Author:   bengunter
Date:     2010-09-23 19:42:31 +0000 (Thu, 23 Sep 2010)

Log Message:
-----------
Fixed STS-760: LinkTagSupport prepends the context name to the href even if the 
href is a relative URL

Modified Paths:
--------------
    branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java

Modified: 
branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java
===================================================================
--- branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java  
2010-09-23 13:18:03 UTC (rev 1268)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/tag/LinkTagSupport.java  
2010-09-23 19:42:31 UTC (rev 1269)
@@ -16,6 +16,7 @@
 
 import net.sourceforge.stripes.exception.StripesJspException;
 import net.sourceforge.stripes.util.CryptoUtil;
+import net.sourceforge.stripes.util.Log;
 import net.sourceforge.stripes.util.UrlBuilder;
 import net.sourceforge.stripes.controller.StripesConstants;
 
@@ -33,6 +34,8 @@
  * @since Stripes 1.4
  */
 public abstract class LinkTagSupport extends HtmlTagSupport implements 
ParameterizableTag {
+    private static final Log log = Log.getInstance(LinkTagSupport.class);
+
     /** Initial value for fields to indicate they were not set by a tag 
attribute. */
     private static final String VALUE_NOT_SET = "VALUE_NOT_SET";
 
@@ -205,12 +208,18 @@
         // Prepend the context path, but only if the user didn't already
         String url = builder.toString();
         String contextPath = request.getContextPath();
-        boolean prepend = prependContext != null && prependContext
-                || prependContext == null && beanclass != null
-                || prependContext == null && contextPath.length() > 1 && 
!url.startsWith(contextPath);
+        if (contextPath.length() > 1) {
+            boolean prepend = prependContext != null && prependContext
+                    || prependContext == null && beanclass != null
+                    || prependContext == null && url.startsWith("/") && 
!url.startsWith(contextPath);
 
-        if (prepend && contextPath.length() > 1)
-            url = contextPath + url;
+            if (prepend) {
+                if (url.startsWith("/"))
+                    url = contextPath + url;
+                else
+                    log.warn("Use of prependContext=\"true\" is only valid 
with a URL that starts with \"/\"");
+            }
+        }
 
         return response.encodeURL(url);
     }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to