mirror of
https://github.com/apache/struts.git
synced 2026-08-05 14:47:09 +00:00
Improves validation RegEx
This commit is contained in:
@@ -81,7 +81,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})*)?" +
|
||||
|
||||
@@ -138,6 +138,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());
|
||||
|
||||
Reference in New Issue
Block a user