diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index 523b57b5a..58d1ac5ed 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -1,7 +1,7 @@ attributes() as $AttrKey => $AttrValue) { if (!isset($result['@attributes'])) { - $result['@attributes'] = array(); + $result['@attributes'] = []; } $result['@attributes'][$AttrKey] = $AttrValue->__toString(); } @@ -147,6 +147,13 @@ class Config extends Singleton } else { $result[$xmlNodeName] = $xmlNode->__toString(); } + // copy attributes to xzy@attribute key item + foreach ($xmlNode->attributes() as $AttrKey => $AttrValue) { + if (!isset($result["${xmlNodeName}@attributes"])) { + $result["${xmlNodeName}@attributes"] = []; + } + $result["${xmlNodeName}@attributes"][$AttrKey] = $AttrValue->__toString(); + } } } } @@ -206,6 +213,15 @@ class Config extends Singleton $node->addAttribute($attrKey, $attrValue); } continue; + } elseif (strstr($itemKey , '@attributes') !== false) { + $origname = str_replace('@attributes', '', $itemKey); + if (count($node->$origname)) { + // copy xml attributes + foreach ($itemValue as $attrKey => $attrValue) { + $node->$origname->addAttribute($attrKey, $attrValue); + } + } + continue; } elseif (is_numeric($itemKey)) { // recurring tag (content), use parent tagname. $childNode = $node->addChild($parentTagName);