From: Dmitry Volyntsev Date: Wed, 4 Oct 2023 22:00:02 +0000 (-0700) Subject: XML: fixed exception handling. X-Git-Tag: 0.8.2~9 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=a6754fe7d81a80d2e6ac99a6b608e6f2b5cda366;p=njs.git XML: fixed exception handling. This closes #675 issue on Github. --- diff --git a/external/njs_xml_module.c b/external/njs_xml_module.c index 2b374501..ae440632 100644 --- a/external/njs_xml_module.c +++ b/external/njs_xml_module.c @@ -2000,7 +2000,7 @@ njs_xml_error(njs_vm_t *vm, njs_xml_doc_t *current, const char *fmt, ...) err->int2); } - njs_vm_error(vm, "%s", p - errstr, errstr); + njs_vm_error(vm, "%*s", p - errstr, errstr); } diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 1078f763..18541204 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -22034,6 +22034,10 @@ static njs_unit_test_t njs_xml_test[] = " doc.root.$tags$.length]"), njs_str("FOO,BAR,0,2") }, + { njs_str("const xml = require('xml');" + "let doc = xml.parse(`GARBAGE`)"), + njs_str("Error: failed to parse XML (libxml2: \"Start tag expected, '<' not found\" at 1:1)") }, + { njs_str("const xml = require('xml');" "let doc = xml.parse(`TEXT`);" "doc.r.$text"),