cvs: pear /Validate Validate.php package.xml
| From: | Pierre-Alain Joye | Date: | Tue, 09 Dec 2003 15:40:29 +0000 |
| Subject: | cvs: pear /Validate Validate.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-14730@lists.php.net to get a copy of this message | ||
pajoye Tue Dec 9 10:40:29 2003 EDT
Modified files:
/pear/Validate Validate.php package.xml
Log:
- Drop Validate::url() in favour of Validate::uri() and rfc2396 compliance
- Addition by Piotr Klaban (<makler@man.torun.pl>):
- ISSN (International Standard Serial Number)
- Add ISMN (International Standard Music Number)
- EAN/UCC-8, EAN/UCC-13 and EAN/UCC-14, UCC-12, SSCC
Index: pear/Validate/Validate.php
diff -u pear/Validate/Validate.php:1.34 pear/Validate/Validate.php:1.35
--- pear/Validate/Validate.php:1.34 Fri Nov 7 08:27:13 2003
+++ pear/Validate/Validate.php Tue Dec 9 10:40:29 2003
@@ -17,7 +17,7 @@
// | Pierre-Alain Joye <paj@pearfr.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Validate.php,v 1.34 2003/11/07 13:27:13 neufeind Exp $
+// $Id: Validate.php,v 1.35 2003/12/09 15:40:29 pajoye Exp $
//
// Methods for common data validations
//
@@ -131,19 +131,37 @@
}
/**
- * Validate a URL
+ * Validate an URI (RFC2396)
*
- * @param string $url URL to validate
- * @param boolean $domain_check Check or not if the domain exists
+ * @param string $url URI to validate
+ * @param array $options Options used by the validation method.
+ * key => type
+ * 'domain_check' => boolean
+ * Whether to check the DNS entry or not
+ * 'allowed_scheme' => array, list of protocols
+ * List of allowed schemes ('http',
+ * 'ssh+svn', 'mms')
*/
- function url($url, $domain_check = false)
+ function uri($url, $options = null)
{
- $purl = parse_url($url);
- if (preg_match('/^(https?|ftp)$/i', @$purl['scheme']) &&
!empty($purl['host'])) {
+ $domain_check = false;
+ $allowed_protocols = null;
+ if (is_array($options)) {
+ extract($options);
+ }
+ if (preg_match(
+ '!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!',
+ $url,$matches)
+ ) {
+ $scheme = $matches[2];
+ $authority = $matches[4];
+ if ( is_array($allowed_schemes) &&
+ !in_array($scheme,$allowed_schemes)
+ ) {
+ return false;
+ }
if ($domain_check && function_exists('checkdnsrr')) {
- if (checkdnsrr($purl['host'], 'A')) {
- return true;
- } else {
+ if (!checkdnsrr($authority, 'A')) {
return false;
}
}
Index: pear/Validate/package.xml
diff -u pear/Validate/package.xml:1.13 pear/Validate/package.xml:1.14
--- pear/Validate/package.xml:1.13 Tue Oct 7 16:16:23 2003
+++ pear/Validate/package.xml Tue Dec 9 10:40:29 2003
@@ -45,31 +45,40 @@
</maintainer>
</maintainers>
<release>
- <version>0.1.2</version>
+ <version>0.3.0</version>
<state>alpha</state>
- <date>2003-??-??</date>
- <notes>
- - Added some dutch validations
+ <date>2003-12-05</date>
+ <notes>- Added Finance Validations for Financial related datas
+ (S. Neufeind, Piotr Klaban)
+- Add polish validation (Piotr Klaban)
+- Small german validation started, more in the next release
+- Add EAN-UCC validtatio (see http://www.ean-ucc.org) (Piotr
Klaban)
+- Add International Standard Serial Number (ISSN)
+ and Music Number(ISMN) (Piotr Klaban)
+- Drop Validate::url() in preferenc of Validate::uri() which is fully
+ RFC2396 compliant
</notes>
<filelist>
<dir name="/">
- <file role="php">Validate.php</file>
- <dir name="Validate">
- <file role="php">ES.php</file>
- <file role="php">US.php</file>
- <file role="php">FR.php</file>
- <file role="php">UK.php</file>
- <file role="php">NL.php</file>
- </dir>
- <dir name="tests" role="test">
- <file>number.php</file>
- <file>date.php</file>
- <file>credit_card.php</file>
- <file>validate_NL.php</file>
- </dir>
- <dir name="docs" role="doc">
- <file>sample_multiple.php</file>
- </dir>
+ <file role="php">Validate.php</file>
+ <dir name="Validate">
+ <file role="php">ES.php</file>
+ <file role="php">US.php</file>
+ <file role="php">FR.php</file>
+ <file role="php">UK.php</file>
+ <file role="php">NL.php</file>
+ <file role="php">US.php</file>
+ <file role="php">PL.php</file>
+ </dir>
+ <dir name="tests" role="test">
+ <file>number.php</file>
+ <file>date.php</file>
+ <file>credit_card.php</file>
+ <file>validate_NL.php</file>
+ </dir>
+ <dir name="docs" role="doc">
+ <file>sample_multiple.php</file>
+ </dir>
</dir>
</filelist>
<deps>
@@ -78,6 +87,12 @@
</release>
<changelog>
<release>
+ <version>0.2.0</version>
+ <state>alpha</state>
+ <date>2003-06-15</date>
+ <notes>- Add some dutch validations</notes>
+ </release>
+ <release>
<version>0.1.1</version>
<state>alpha</state>
<date>2003-03-12</date>