You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2016/06/14 04:54:19 UTC
struts git commit: Improves validation RegEx
Repository: struts
Updated Branches:
refs/heads/support-2-3 1c92a8b2c -> eccc31ebc
Improves validation RegEx
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/eccc31eb
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/eccc31eb
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/eccc31eb
Branch: refs/heads/support-2-3
Commit: eccc31ebce5430f9e91b9684c63eaaf885e603f9
Parents: 1c92a8b
Author: Lukasz Lenart <lu...@apache.org>
Authored: Tue Jun 14 06:53:36 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Tue Jun 14 06:53:36 2016 +0200
----------------------------------------------------------------------
.../com/opensymphony/xwork2/validator/validators/URLValidator.java | 2 +-
.../java/com/opensymphony/xwork2/validator/URLValidatorTest.java | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/eccc31eb/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 767416d..9aa3c9d 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
@@ -82,7 +82,7 @@ public class URLValidator extends FieldValidatorSupport {
"|((\\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})*)*" +
+ ")(((\\/{0,1}([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)*" +
"(\\?([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)" +
"?)?)?" +
"(#([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)?" +
http://git-wip-us.apache.org/repos/asf/struts/blob/eccc31eb/xwork-core/src/test/java/com/opensymphony/xwork2/validator/URLValidatorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/URLValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/URLValidatorTest.java
index f495557..da9806a 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/URLValidatorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/URLValidatorTest.java
@@ -139,6 +139,7 @@ public class URLValidatorTest extends XWorkTestCase {
assertFalse(pattern.matcher("").matches());
assertFalse(pattern.matcher(" ").matches());
assertFalse(pattern.matcher("no url").matches());
+ assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());
assertTrue(pattern.matcher("http://www.opensymphony.com").matches());
assertTrue(pattern.matcher("https://www.opensymphony.com").matches());