From 67ea92905fbe42e091ceaefda20c514e2b33df1e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 15:48:49 +0300 Subject: [PATCH 1/2] test(inputters): Make sure XML reader doesn't give us non-key/value options --- inputters/xml_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inputters/xml_spec.lua b/inputters/xml_spec.lua index 3b2077e41..8ba7efce0 100644 --- a/inputters/xml_spec.lua +++ b/inputters/xml_spec.lua @@ -36,6 +36,11 @@ describe("#XML #inputter", function () assert.is.equal("bar", t[1]) end) + it("commands should parse only named arguments", function () + local t = inputter:parse([[bar]])[1][1] + assert.is.equal(0, #t.options) + end) + -- it("commands with quoted arg with escape", function() -- local t = inputter:parse([[bar]]) -- assert.is.equal("foo", t.command) From 4bb31f0aefaf9da500f417a73302ef148ec36a65 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 16:36:14 +0300 Subject: [PATCH 2/2] fix(inputters): Discard duplicate values being parsed without keys in XML --- inputters/xml.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/inputters/xml.lua b/inputters/xml.lua index 01573137d..bb4242c2a 100644 --- a/inputters/xml.lua +++ b/inputters/xml.lua @@ -7,6 +7,12 @@ inputter._name = "xml" inputter.order = 2 local function startcommand (parser, command, options) + -- Discard list values (non-key/value), stuffed by LXP/expat to make it possible to deduce the order of keys in + -- the source. We're not using it, so we don't care and it is clutter in the AST that makes it different from + -- ASTs generated from SIL inputs. + for i = 1, #options do + options[i] = nil + end local stack = parser:getcallbacks().stack local lno, col, pos = parser:pos() local position = { lno = lno, col = col, pos = pos }