Author: mgrigorov
Date: Sat Sep 25 17:12:27 2010
New Revision: 1001275

URL: http://svn.apache.org/viewvc?rev=1001275&view=rev
Log:
WICKET-3076 UrlUtils.isRelative returns false if URL parameter contains an 
absolute URL

Use regular expression to check whether the passed url string starts with 
'scheme://'

merge r1001273 from 1.5.x


Added:
    
wicket/branches/wicket-1.4.x/wicket/src/test/java/org/apache/wicket/util/string/UrlUtilsTest.java
      - copied unchanged from r1001273, 
wicket/trunk/wicket/src/test/java/org/apache/wicket/util/string/UrlUtilsTest.java
Modified:
    
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java?rev=1001275&r1=1001274&r2=1001275&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/string/UrlUtils.java
 Sat Sep 25 17:12:27 2010
@@ -39,9 +39,10 @@ public class UrlUtils
         * @param url
         * @return <code>true</code> if url is relative, <code>false</code> 
otherwise
         */
-       public static boolean isRelative(String url)
+       public static boolean isRelative(final String url)
        {
-               if ((url != null) && (url.startsWith("/") == false) && 
(url.indexOf("://") < 0) &&
+               // the regex means "doesn't start with 'scheme://'"
+               if ((url != null) && (url.startsWith("/") == false) && 
(!url.matches("^\\w+\\:\\/\\/.*")) &&
                        !(url.startsWith("#")))
                {
                        return true;


Reply via email to