]> granicus.if.org Git - php/commitdiff
* add PEAR_COMMON_PACKAGE_NAME_PREG constant
authorStig Bakken <ssb@php.net>
Thu, 6 Jun 2002 10:16:42 +0000 (10:16 +0000)
committerStig Bakken <ssb@php.net>
Thu, 6 Jun 2002 10:16:42 +0000 (10:16 +0000)
pear/PEAR/Common.php

index b75486e1a27b5c40304a3b7a4543cfa737d21747..0c3f4953069a1e89b44527c273dc9c2b0fb5514a 100644 (file)
@@ -24,7 +24,9 @@ require_once 'Archive/Tar.php';
 require_once 'System.php';
 require_once 'PEAR/Config.php';
 
-// {{{ globals
+// {{{ constants and globals
+
+define('PEAR_COMMON_PACKAGE_NAME_PREG', '/^([A-Z][a-zA-Z0-9_]+|[a-z][a-z0-9_]+)$/');
 
 /**
  * List of temporary files and directories registered by
@@ -481,6 +483,7 @@ class PEAR_Common extends PEAR
             case 'name':
                 switch ($this->prev_element) {
                     case 'package':
+                        // XXX should we check the package name here?
                         $this->pkginfo['package'] = ereg_replace('[^a-zA-Z0-9._]', '_', $data);
                         break;
                     case 'maintainer':
@@ -1355,7 +1358,7 @@ class PEAR_Common extends PEAR
      */
     function validPackageName($name)
     {
-        return (bool)preg_match('/^[A-Z][A-Za-z0-9_]+$/', $name);
+        return (bool)preg_match(PEAR_COMMON_PACKAGE_NAME_PREG, $name);
     }