Permalink
Browse files

Updated url regular expression check

  • Loading branch information...
1 parent 7a3ab43 commit 255d7924c75c35e8db9b8ff12375bee151df1bf6 @Stardog Stardog committed Jan 7, 2016
Showing with 12 additions and 1 deletion.
  1. +8 −1 Global/Variable/Url.php
  2. +3 −0 docs/CREDITS.txt
  3. +1 −0 mod/election
@@ -16,6 +16,13 @@ class Url extends String {
*/
protected $input_type = 'url';
+
+ /**
+ * This brain-frying regular expression was written by Diego Perini @ https://gist.github.com/dperini/729294
+ * @var string
+ */
+ protected $regexp_match = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$_iuS';
+
/**
* Checks the value to ensure it is a proper url.
* The construct will throw an exception if the string does not pass.
@@ -24,7 +31,7 @@ class Url extends String {
*/
public function __construct($value = null, $varname = null)
{
- $this->setRegexpMatch('/^(https?:\/\/|\.\/|\/\/)?\w([,\.\w\-\/&;?\+=~#])+$/i');
+ //$this->setRegexpMatch('/^(https?:\/\/|\.\/|\/\/)?\w([,\.\w\-\/&;?\+=~#])+$/i');
parent::__construct($value, $varname);
}
View
@@ -153,6 +153,9 @@ Chupurnov Valeriy
XDSoft
http://xdsoft.net/
+Diego Perini
+URL regular expression code
+https://gist.github.com/dperini/
--------------------------------------------------------------------------
To those who translate, we salute you.
View

0 comments on commit 255d792

Please sign in to comment.