cvs: pear /XML_Util Util.php /XML_Util/examples example.php
| From: | Stephan Schmidt | Date: | Sun, 27 Jun 2004 18:15:14 +0000 |
| Subject: | cvs: pear /XML_Util Util.php /XML_Util/examples example.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-21195@lists.php.net to get a copy of this message | ||
schst Sun Jun 27 14:15:14 2004 EDT
Modified files:
/pear/XML_Util Util.php
/pear/XML_Util/examples example.php
Log:
added check for tag name in createTagFromArray() (bug 1083)
http://cvs.php.net/diff.php/pear/XML_Util/Util.php?r1=1.19&r2=1.20&ty=u
Index: pear/XML_Util/Util.php
diff -u pear/XML_Util/Util.php:1.19 pear/XML_Util/Util.php:1.20
--- pear/XML_Util/Util.php:1.19 Mon May 24 14:58:31 2004
+++ pear/XML_Util/Util.php Sun Jun 27 14:15:13 2004
@@ -16,7 +16,7 @@
// | Authors: Stephan Schmidt <schst@php-tools.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Util.php,v 1.19 2004/05/24 18:58:31 schst Exp $
+// $Id: Util.php,v 1.20 2004/06/27 18:15:13 schst Exp $
/**
* error code for invalid chars in XML name
@@ -34,6 +34,11 @@
define("XML_UTIL_ERROR_NON_SCALAR_CONTENT", 60);
/**
+ * error code for missing tag name
+ */
+define("XML_UTIL_ERROR_NO_TAG_NAME", 61);
+
+/**
* replace XML entities
*/
define("XML_UTIL_REPLACE_ENTITIES", 1);
@@ -372,6 +377,10 @@
{
if (isset($tag["content"]) && !is_scalar($tag["content"])) {
return XML_Util::raiseError( "Supplied non-scalar value as tag content",
XML_UTIL_ERROR_NON_SCALAR_CONTENT );
+ }
+
+ if (!isset($tag['qname']) && !isset($tag['localPart'])) {
+ return XML_Util::raiseError( 'You must either supply a qualified name (qname) or
local tag name (localPart).', XML_UTIL_ERROR_NO_TAG_NAME );
}
// if no attributes hav been set, use empty attributes
http://cvs.php.net/diff.php/pear/XML_Util/examples/example.php?r1=1.8&r2=1.9&ty=u
Index: pear/XML_Util/examples/example.php
diff -u pear/XML_Util/examples/example.php:1.8 pear/XML_Util/examples/example.php:1.9
--- pear/XML_Util/examples/example.php:1.8 Fri Sep 26 16:03:38 2003
+++ pear/XML_Util/examples/example.php Sun Jun 27 14:15:14 2004
@@ -1,4 +1,6 @@
<?PHP
+ error_reporting(E_ALL);
+
require_once 'XML/Util.php';
/**
@@ -182,4 +184,15 @@
print "</pre>";
print "\n<br><br>\n";
+ /**
+ * trying to create an XML tag without a name
+ */
+ $tag = array(
+ "attributes" => array( "foo" => "bar" ),
+ );
+ print "trying to create an XML tag without a name:<br>\n";
+ print "<pre>";
+ print_r(XML_Util::createTagFromArray($tag));
+ print "</pre>";
+ print "\n<br><br>\n";
?>