mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-03-14 18:11:55 +01:00
Fix xml tests with libxml2 >=2.13.
Original errors:
```
njs("const xml = require('xml');let data = `<note><to b="bar" a= "foo" >Tove</to><from>Jani</from></note>`;let doc = xml.parse(data);var doc2 = xml.parse(`<n0:pdu xmlns:n0="http://a"></n0:pdu>`);doc.note.$tags = [doc.note.to, doc2];(new TextDecoder).decode(xml.c14n(doc))")
expected: "<note xmlns:n0="http://a"><to a="foo" b="bar">Tove</to><n0:pdu></n0:pdu></note>"
got: "<note></note>"
njs("const xml = require('xml');let data = `<note><to b="bar" a= "foo" >Tove</to><from>Jani</from></note>`;let doc = xml.parse(data);var doc2 = xml.parse(`<n0:pdu xmlns:n0="http://a"></n0:pdu>`);doc.note.$tags = [doc2, doc.note.to];(new TextDecoder).decode(xml.c14n(doc))")
expected: "<note xmlns:n0="http://a"><n0:pdu></n0:pdu><to a="foo" b="bar">Tove</to></note>"
got: "<note></note>"
xml tests: FAILED [44/46]
```
69 lines
2.2 KiB
Diff
69 lines
2.2 KiB
Diff
Source: https://github.com/nginx/njs/pull/817.patch
|
|
--
|
|
From 21ce0d970ee46252b03dad2b624660a7dd50076d Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Volyntsev <xeioex@nginx.com>
|
|
Date: Wed, 6 Nov 2024 22:08:21 -0800
|
|
Subject: [PATCH 1/2] XML: fixed tests with libxml2 2.13 and later.
|
|
|
|
This fixes #812 issue on Github.
|
|
---
|
|
external/njs_xml_module.c | 8 ++------
|
|
1 file changed, 2 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/external/njs_xml_module.c b/external/njs_xml_module.c
|
|
index 86c896c0e..d9f3bbb5f 100644
|
|
--- a/external/njs_xml_module.c
|
|
+++ b/external/njs_xml_module.c
|
|
@@ -1275,17 +1275,13 @@ njs_xml_node_tags_handler(njs_vm_t *vm, xmlNode *current, njs_str_t *name,
|
|
|
|
/* set or delete. */
|
|
|
|
- copy = xmlDocCopyNode(current, current->doc, 1);
|
|
+ copy = xmlDocCopyNode(current, current->doc,
|
|
+ 2 /* copy properties and namespaces */);
|
|
if (njs_slow_path(copy == NULL)) {
|
|
njs_vm_internal_error(vm, "xmlDocCopyNode() failed");
|
|
return NJS_ERROR;
|
|
}
|
|
|
|
- if (copy->children != NULL) {
|
|
- xmlFreeNodeList(copy->children);
|
|
- copy->children = NULL;
|
|
- }
|
|
-
|
|
if (retval == NULL) {
|
|
/* delete. */
|
|
return njs_xml_replace_node(vm, current, copy);
|
|
|
|
From 6f4fc571b0d4df2a171e86ec325adbb6c7eb9d77 Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Volyntsev <xeioex@nginx.com>
|
|
Date: Wed, 6 Nov 2024 22:15:22 -0800
|
|
Subject: [PATCH 2/2] XML: improved XMLNode.$tags handler.
|
|
|
|
---
|
|
external/njs_xml_module.c | 10 +++++-----
|
|
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/external/njs_xml_module.c b/external/njs_xml_module.c
|
|
index d9f3bbb5f..d5ab9ddd4 100644
|
|
--- a/external/njs_xml_module.c
|
|
+++ b/external/njs_xml_module.c
|
|
@@ -1318,12 +1318,12 @@ njs_xml_node_tags_handler(njs_vm_t *vm, xmlNode *current, njs_str_t *name,
|
|
xmlFreeNode(node);
|
|
goto error;
|
|
}
|
|
+ }
|
|
|
|
- ret = xmlReconciliateNs(current->doc, copy);
|
|
- if (njs_slow_path(ret == -1)) {
|
|
- njs_vm_internal_error(vm, "xmlReconciliateNs() failed");
|
|
- goto error;
|
|
- }
|
|
+ ret = xmlReconciliateNs(current->doc, copy);
|
|
+ if (njs_slow_path(ret == -1)) {
|
|
+ njs_vm_internal_error(vm, "xmlReconciliateNs() failed");
|
|
+ goto error;
|
|
}
|
|
|
|
njs_value_undefined_set(retval);
|