struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4834 Improve RegEx used to validate URLs
Date Mon, 07 Aug 2017 06:33:06 GMT
Repository: struts
Updated Branches:
  refs/heads/support-2-3 744c1f409 -> 3fddfb6eb


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/3fddfb6e
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/3fddfb6e
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/3fddfb6e

Branch: refs/heads/support-2-3
Commit: 3fddfb6eb562d597c935084e9e81d43ed6bcd02c
Parents: 744c1f4
Author: Stefaan Dutry <stefaan.dutry@gmail.com>
Authored: Fri Aug 4 13:58:31 2017 +0200
Committer: Stefaan Dutry <stefaan.dutry@gmail.com>
Committed: Fri Aug 4 13:58:31 2017 +0200

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


http://git-wip-us.apache.org/repos/asf/struts/blob/3fddfb6e/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
index b46dea3..f72aad8 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java
@@ -73,19 +73,18 @@ public class URLValidator extends FieldValidatorSupport {
         } else if (StringUtils.isNotEmpty(urlRegex)) {
             return urlRegex;
         } else {
-            return "^(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]\\.)*" +
+            return "^(?: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})*)?" +
                     "$";
         }
     }


Mime
View raw message