struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sdu...@apache.org
Subject struts git commit: WW-4834 Improve RegEx used to validate URLs
Date Wed, 02 Aug 2017 06:57:12 GMT
Repository: struts
Updated Branches:
  refs/heads/master 7f90a4fec -> 9d47af6ff


WW-4834 Improve RegEx used to validate URLs


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9d47af6f
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9d47af6f
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9d47af6f

Branch: refs/heads/master
Commit: 9d47af6ffa355977b5acc713e6d1f25fac260a28
Parents: 7f90a4f
Author: Stefaan Dutry <stefaan.dutry@gmail.com>
Authored: Tue Aug 1 17:33:53 2017 +0200
Committer: Stefaan Dutry <stefaan.dutry@gmail.com>
Committed: Tue Aug 1 17:33:53 2017 +0200

----------------------------------------------------------------------
 .../validator/validators/URLValidator.java      | 23 ++++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/9d47af6f/core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
b/core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
index 6cf58ef..b61f786 100644
--- a/core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
+++ b/core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
@@ -48,19 +48,18 @@ public class URLValidator extends FieldValidatorSupport {
 
     private static final Logger LOG = LogManager.getLogger(URLValidator.class);
 
-    public static final String DEFAULT_URL_REGEX = "^(https?|ftp):\\/\\/" +
-            "(([a-z0-9$_\\.\\+!\\*\\'\\(\\),;\\?&=\\-]|%[0-9a-f]{2})+" +
-            "(:([a-z0-9$_\\.\\+!\\*\\'\\(\\),;\\?&=\\-]|%[0-9a-f]{2})+)?" +
-            "@)?(#?" +
-            ")((([a-z0-9]\\.|[a-z0-9][a-z0-9-]*[a-z0-9]\\.)*" +
+    public static final String DEFAULT_URL_REGEX = "^(?:https?|ftp)://" +
+            "(?:(?:[a-z0-9$_.+!*'(),;?&=\\-]|%[0-9a-f]{2})+" +
+            "(?::(?:[a-z0-9$_.+!*'(),;?&=\\-]|%[0-9a-f]{2})+)?" +
+            "@)?#?" +
+            "(?:(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)*" +
             "[a-z][a-z0-9-]*[a-z0-9]" +
-            "|((\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
-            "(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])" +
-            ")(:\\d+)?" +
-            ")(((\\/([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=\\-]|%[0-9a-f]{2})*)*" +
-            "(\\?([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=\\-\\/\\:]|%[0-9a-f]{2})*)" +
-            "?)?)?" +
-            "(#([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=\\-]|%[0-9a-f]{2})*)?" +
+            "|(?:[1-9]?\\d|1\\d{2}|2[0-4]\\d|25[0-5]\\.){3}" +
+            "[1-9]?\\d|1\\d{2}|2[0-4]\\d|25[0-5]" +
+            ")(?::\\d+)?" +
+            ")(?:(?:/(?:[a-z0-9$_.+!*'(),;:@&=\\-]|%[0-9a-f]{2})*)*" +
+            "(?:\\?(?:[a-z0-9$_.+!*'(),;:@&=\\-/:]|%[0-9a-f]{2})*)?)?" +
+            "(?:#(?:[a-z0-9$_.+!*'(),;:@&=\\-]|%[0-9a-f]{2})*)?" +
             "$";
 
     private String urlRegexExpression;


Mime
View raw message