cvs: pear /CodeGen/CodeGen ExtensionParser.php XmlParser.php
| From: | Hartmut Holzgraefe | Date: | Mon, 20 Feb 2006 20:18:23 +0000 |
| Subject: | cvs: pear /CodeGen/CodeGen ExtensionParser.php XmlParser.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-38408@lists.php.net to get a copy of this message | ||
hholzgra Mon Feb 20 20:18:23 2006 UTC
Modified files:
/pear/CodeGen/CodeGen ExtensionParser.php XmlParser.php
Log:
stricter attribute checking
http://cvs.php.net/viewcvs.cgi/pear/CodeGen/CodeGen/ExtensionParser.php?r1=1.10&r2=1.11&diff_format=u
Index: pear/CodeGen/CodeGen/ExtensionParser.php
diff -u pear/CodeGen/CodeGen/ExtensionParser.php:1.10 pear/CodeGen/CodeGen/ExtensionParser.php:1.11
--- pear/CodeGen/CodeGen/ExtensionParser.php:1.10 Thu Feb 2 22:14:57 2006
+++ pear/CodeGen/CodeGen/ExtensionParser.php Mon Feb 20 20:18:23 2006
@@ -15,7 +15,7 @@
* @author Hartmut Holzgraefe <hartmut@php.net>
* @copyright 2005 Hartmut Holzgraefe
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: ExtensionParser.php,v 1.10 2006/02/02 22:14:57 hholzgra Exp $
+ * @version CVS: $Id: ExtensionParser.php,v 1.11 2006/02/20 20:18:23 hholzgra Exp $
* @link http://pear.php.net/package/CodeGen
*/
@@ -116,6 +116,18 @@
/**
+ * Handle <extension><summary>
+ *
+ * @access private
+ * @param array attribute/value pairs
+ * @return bool success status
+ */
+ function tagend_extension_summary($attr)
+ {
+ return $this->noAttributes($attr);
+ }
+
+ /**
* Handle <extension></summary>
*
* @access private
@@ -129,6 +141,18 @@
}
/**
+ * Handle <extension><description>
+ *
+ * @access private
+ * @param array attribute/value pairs
+ * @return bool success status
+ */
+ function tagend_extension_description($attr)
+ {
+ return $this->noAttributes($attr);
+ }
+
+ /**
* Handle <extension></description>
*
* @access private
@@ -148,24 +172,44 @@
function tagstart_maintainer($attr)
{
$this->pushHelper(new CodeGen_Maintainer);
- return true;
+ return $this->noAttributes($attr);;
}
+ function tagstart_maintainer_user($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_maintainer_user($attr, $data)
{
return $this->helper->setUser(trim($data));
}
+ function tagstart_maintainer_name($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_maintainer_name($attr, $data)
{
return $this->helper->setName(trim($data));
}
+ function tagstart_maintainer_email($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_maintainer_email($attr, $data)
{
return $this->helper->setEmail(trim($data));
}
+ function tagstart_maintainer_role($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_maintainer_role($attr, $data)
{
return $this->helper->setRole(trim($data));
@@ -186,7 +230,12 @@
function tagstart_extension_release($attr)
{
$this->pushHelper(new CodeGen_Release);
- return true;
+ return $this->noAttributes($attr);;
+ }
+
+ function tagstart_release_version($attr)
+ {
+ return $this->noAttributes($attr);;
}
function tagend_release_version($attr, $data)
@@ -194,16 +243,31 @@
return $this->helper->setVersion(trim($data));
}
+ function tagstart_release_date($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_release_date($attr, $data)
{
return $this->helper->setDate(trim($data));
}
+ function tagstart_release_state($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_release_state($attr, $data)
{
return $this->helper->setState(trim($data));
}
+ function tagstart_release_notes($attr)
+ {
+ return $this->noAttributes($attr);;
+ }
+
function tagend_release_notes($attr, $data)
{
return $this->helper->setNotes(CodeGen_Tools_Indent::linetrim($data));
@@ -219,6 +283,7 @@
function tagstart_extension_changelog($attr, $data)
{
$this->verbatim();
+ return $this->noAttributes($attr);;
}
function tagend_extension_changelog($attr, $data)
@@ -239,6 +304,11 @@
}
function tagend_extension_code($attr, $data) {
+ $err = $this->checkAttributes($attr, array("role", "position"));
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+
$role = isset($attr["role"]) ? $attr["role"] :
"code";
$position = isset($attr["position"]) ? $attr["position"] :
"bottom";
@@ -252,6 +322,11 @@
function tagstart_deps($attr)
{
+ $err = $this->checkAttributes($attr, array("platform","language"));
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+
if (isset($attr["platform"])) {
$err = $this->extension->setPlatform($attr["platform"]);
if (PEAR::isError($err)) {
@@ -270,6 +345,11 @@
function tagstart_deps_file($attr)
{
+ $err = $this->checkAttributes($attr, array("name"));
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+
if (!isset($attr['name'])) {
return PEAR::raiseError("name attribut for file missing");
}
@@ -279,6 +359,15 @@
function tagstart_deps_lib($attr)
{
+ $err = $this->checkAttributes($attr, array("name", "platform"));
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+
+ if (!isset($attr['name'])) {
+ return PEAR::raiseError("name attribut for lib missing");
+ }
+
$this->extension->libs[$attr['name']] = $attr;
if (isset($attr['platform'])) {
$platform = new CodeGen_Tools_Platform($attr["platform"]);
@@ -296,6 +385,15 @@
function tagstart_deps_header($attr)
{
+ $err = $this->checkAttributes($attr, array("name", "prepend",
"path"));
+ if (PEAR::isError($err)) {
+ return $err;
+ }
+
+ if (!isset($attr['name'])) {
+ return PEAR::raiseError("name attribut for lib missing");
+ }
+
$this->extension->headers[$attr['name']] = $attr;
}
}
http://cvs.php.net/viewcvs.cgi/pear/CodeGen/CodeGen/XmlParser.php?r1=1.12&r2=1.13&diff_format=u
Index: pear/CodeGen/CodeGen/XmlParser.php
diff -u pear/CodeGen/CodeGen/XmlParser.php:1.12 pear/CodeGen/CodeGen/XmlParser.php:1.13
--- pear/CodeGen/CodeGen/XmlParser.php:1.12 Sat Feb 4 19:17:32 2006
+++ pear/CodeGen/CodeGen/XmlParser.php Mon Feb 20 20:18:23 2006
@@ -15,7 +15,7 @@
* @author Hartmut Holzgraefe <hartmut@php.net>
* @copyright 2005 Hartmut Holzgraefe
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: XmlParser.php,v 1.12 2006/02/04 19:17:32 hholzgra Exp $
+ * @version CVS: $Id: XmlParser.php,v 1.13 2006/02/20 20:18:23 hholzgra Exp $
* @link http://pear.php.net/package/CodeGen
*/
@@ -559,6 +559,19 @@
}
+ /**
+ * Check that no attributes are given
+ *
+ */
+ protected function noAttributes($attr)
+ {
+ if (!empty($attr)) {
+ return PEAR::raiseError("<".end($this->tagStack)."> does not allow any
attributes");
+ }
+
+ return true;
+ }
+
/**
* Check attributes
*