瀏覽代碼

Поправлен баг в fromObject

Book Pauk 2 年之前
父節點
當前提交
772ea3ca0c
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      server/core/xml/XmlParser.js

+ 4 - 2
server/core/xml/XmlParser.js

@@ -734,8 +734,8 @@ class XmlParser extends NodeBase {
                 } else if (tag === '*ATTRS') {
                 } else if (tag === '*ATTRS') {
                     //пропускаем
                     //пропускаем
                 } else {
                 } else {
-                    if (typeof(objNode) === 'string') {
-                        result.push(this.createNode(tag, null, [this.createText(objNode).raw]).raw);
+                    if (typeof(objNode) === 'string' || typeof(objNode) === 'number') {
+                        result.push(this.createNode(tag, null, [this.createText(objNode.toString()).raw]).raw);
                     } else if (Array.isArray(objNode)) {
                     } else if (Array.isArray(objNode)) {
                         for (const n of objNode) {
                         for (const n of objNode) {
                             if (typeof(n) === 'string') {
                             if (typeof(n) === 'string') {
@@ -747,6 +747,8 @@ class XmlParser extends NodeBase {
 
 
                     } else if (typeof(objNode) === 'object') {
                     } else if (typeof(objNode) === 'object') {
                         result.push(this.createNode(tag, (objNode['*ATTRS'] ? Object.entries(objNode['*ATTRS']) : null), objectToNodes(objNode)).raw);
                         result.push(this.createNode(tag, (objNode['*ATTRS'] ? Object.entries(objNode['*ATTRS']) : null), objectToNodes(objNode)).raw);
+                    } else {
+                        throw new Error(`Unknown node type "${typeof(objNode)}" of node: ${objNode}`);
                     }
                     }
                 }
                 }
             }
             }