diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-28 16:11:34 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-28 16:11:34 +0000 |
commit | 684996f42d9691834b39c316bdd8ac22a716dd45 (patch) | |
tree | 86a7174ac48e37b2557ae4a6d1a7822e5c869e9b | |
parent | c9cf47dc0ea54acaa92d59a98dc1d59e6b63537e (diff) | |
download | elgg-684996f42d9691834b39c316bdd8ac22a716dd45.tar.gz elgg-684996f42d9691834b39c316bdd8ac22a716dd45.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Sanity checks added to OpenDD import
git-svn-id: https://code.elgg.org/elgg/trunk@750 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/opendd.php | 18 |
1 files changed, 15 insertions, 3 deletions
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; } |