[pLog-svn] r2150 - plog/branches/plog-1.0.2/class/data/validator
jondaley at devel.plogworld.net
jondaley at devel.plogworld.net
Wed Jun 1 00:38:58 GMT 2005
Author: jondaley
Date: 2005-06-01 00:38:58 +0000 (Wed, 01 Jun 2005)
New Revision: 2150
Modified:
plog/branches/plog-1.0.2/class/data/validator/httpurlvalidator.class.php
Log:
the validator now ... validates. http://bugs.plogworld.net/view.php?id=551 Probably we are going to find people who use bad urls who aren't going to like this validator.
Modified: plog/branches/plog-1.0.2/class/data/validator/httpurlvalidator.class.php
===================================================================
--- plog/branches/plog-1.0.2/class/data/validator/httpurlvalidator.class.php 2005-05-31 21:46:38 UTC (rev 2149)
+++ plog/branches/plog-1.0.2/class/data/validator/httpurlvalidator.class.php 2005-06-01 00:38:58 UTC (rev 2150)
@@ -15,10 +15,28 @@
{
function HttpUrlValidator()
{
+ // trying to be RFC 1736 compatible, except where common
+ // usage goes against it, such as allowing unencoded
+ // '~', '^', ' ', etc.
+
+ $prefix = "^([[:alnum:]\-\+\.]+)\://";
+ $ftp_login = "([[:alnum:]\.\-]+(\:[[:alnum:]\.&%\$\-]+)*@)*";
+ $ip_num = "(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]?)";
+ $ip_address = "($ip_num\.($ip_num|0)\.($ip_num|0)\.$ip_num)";
+ $tld = "(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|([[:alpha:]]{2}))";
+ $port = "(\:[[:digit:]]+)*";
+ $path = "(/($|[[:alnum:] \.\,\?\'\"\\\+^&%\$#\=~_\-]+))*";
+
+ // allow underscores, even though we shouldn't
+ $domain_part = "([[:alnum:]_\-]+\.)+";
+
$this->Validator();
-
$this->addRule( new NonEmptyRule());
- //$this->addRule( new RegExpRule( "!^http(s)?:\/\/\w+\.\w+(\S+)?$!", false ));
+ $this->addRule( new RegExpRule($prefix . $ftp_login .
+ "(" . $ip_address . "|localhost|(" .
+ $domain_part . $tld . "))" .
+ $port . $path . "$",
+ false ));
}
}
-?>
\ No newline at end of file
+?>
More information about the pLog-svn
mailing list