From 684996f42d9691834b39c316bdd8ac22a716dd45 Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 28 May 2008 16:11:34 +0000 Subject: Marcus Povey * Sanity checks added to OpenDD import git-svn-id: https://code.elgg.org/elgg/trunk@750 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/opendd.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/opendd.php b/engine/lib/opendd.php index 60707f43f..ec1829bcc 100644 --- a/engine/lib/opendd.php +++ b/engine/lib/opendd.php @@ -6,7 +6,7 @@ * @subpackage Core * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Marcus Povey - * @version 0.2 + * @version 0.3 * @copyright Curverider Ltd 2008 * @link http://elgg.org/ */ @@ -308,22 +308,34 @@ * @return ODDDocument */ function ODD_Import($xml) - { + { // Parse XML to an array $elements = xml_2_object($xml); + + // Sanity check 1, was this actually XML? + if ((!$elements) || (!$elements->children)) + return false; // Create ODDDocument $document = new ODDDocument(); // Itterate through array of elements and construct ODD document + $cnt = 0; + foreach ($elements->children as $child) { $odd = ODD_factory($child); - if ($odd) + if ($odd) { $document->addElement($odd); + $cnt++; + } } + // Check that we actually found something + if ($cnt == 0) + return false; + return $document; } -- cgit v1.2.3