nginx / njs

A subset of JavaScript language to use in nginx
http://nginx.org/en/docs/njs/
BSD 2-Clause "Simplified" License
1.17k stars 153 forks source link

Some XML tests fail with latest libxml2 #812

Open jirutka opened 2 hours ago

jirutka commented 2 hours ago

Describe the bug

Two XML tests in njs_unit_test.c fail:

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]

It’s failing even on njs 0.8.4, so it’s most likely related to the latest libxml2 version (2.13.4).

To reproduce

apk add build-base libedit-dev libxml2-dev openssl-dev pcre-dev expect
./configure
make njs
make test

Expected behavior

All tests should pass.

Your environment

thresheek commented 2 hours ago

Can this be related to https://github.com/nginx/nginx/issues/251 ?

jirutka commented 1 hour ago

I don’t think so, we have already applied the upstream patch https://gitlab.gnome.org/GNOME/libxml2/-/commit/efb57ddba3571928395644568444990e8ea831ea.