From cb9f82195f5daec51a2ccdfda4fdc29d2a2a3e24 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 29 Mar 2015 12:09:54 +0200 Subject: [PATCH] validate fromArray in config class to ignore empty tags. If for some strange reason the frontend code drops empty tags, we need to ignore them. Related to https://github.com/opnsense/core/issues/116 --- src/opnsense/mvc/app/library/OPNsense/Core/Config.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index 0d2c4396d..960dcf22c 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -112,7 +112,7 @@ class Config extends Singleton // single content item if (is_array($forceList) && array_key_exists($xmlNode->getName(), $forceList)) { $result[$xmlNode->getName()] = array(); - if ($xmlNode->__toString() != null && trim($xmlNode->__toString()) !== "" ){ + if ($xmlNode->__toString() != null && trim($xmlNode->__toString()) !== "") { $result[$xmlNode->getName()][] = $xmlNode->__toString(); } } else { @@ -143,8 +143,9 @@ class Config extends Singleton } foreach ($source as $itemKey => $itemValue) { - if (is_bool($itemValue) && $itemValue == false) { - // skip empty booleans + if ((is_bool($itemValue) && $itemValue == false) || // skip empty booleans + $itemKey == null || trim($itemKey) == "" // skip empty tag names + ) { continue; } if (is_numeric($itemKey)) {