Skip to content

Commit 418a20c

Browse files
committed
further fixed faulty RegEx: missing grouping for last number in ip-address and escaped '/' to work in javascript
1 parent 8a04e80 commit 418a20c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

core/src/main/java/com/opensymphony/xwork2/validator/validators/URLValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ public class URLValidator extends FieldValidatorSupport {
4848

4949
private static final Logger LOG = LogManager.getLogger(URLValidator.class);
5050

51-
public static final String DEFAULT_URL_REGEX = "^(?:https?|ftp)://" +
51+
public static final String DEFAULT_URL_REGEX = "^(?:https?|ftp):\\/\\/" +
5252
"(?:(?:[a-z0-9$_.+!*'(),;?&=\\-]|%[0-9a-f]{2})+" +
5353
"(?::(?:[a-z0-9$_.+!*'(),;?&=\\-]|%[0-9a-f]{2})+)?" +
5454
"@)?#?" +
5555
"(?:(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)*" +
5656
"[a-z][a-z0-9-]*[a-z0-9]" +
5757
"|(?:(?:[1-9]?\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}" +
58-
"[1-9]?\\d|1\\d{2}|2[0-4]\\d|25[0-5]" +
58+
"(?:[1-9]?\\d|1\\d{2}|2[0-4]\\d|25[0-5])" +
5959
")(?::\\d+)?" +
60-
")(?:(?:/(?:[a-z0-9$_.+!*'(),;:@&=\\-]|%[0-9a-f]{2})*)*" +
61-
"(?:\\?(?:[a-z0-9$_.+!*'(),;:@&=\\-/:]|%[0-9a-f]{2})*)?)?" +
60+
")(?:(?:\\/(?:[a-z0-9$_.+!*'(),;:@&=\\-]|%[0-9a-f]{2})*)*" +
61+
"(?:\\?(?:[a-z0-9$_.+!*'(),;:@&=\\-\\/:]|%[0-9a-f]{2})*)?)?" +
6262
"(?:#(?:[a-z0-9$_.+!*'(),;:@&=\\-]|%[0-9a-f]{2})*)?" +
6363
"$";
6464

0 commit comments

Comments
 (0)