From fa69bf036d86cead71d3ff2a53a6287af3940f99 Mon Sep 17 00:00:00 2001 From: Jurriaan Barkey Wolf Date: Sat, 5 Jun 2021 12:05:10 +0200 Subject: [PATCH] #214 Allow arrays as the result of INS commands again. --- .../__snapshots__/templating.test.ts.snap | 448 ++++++++++++++++++ src/__tests__/fixtures/insertArray.docx | Bin 0 -> 12044 bytes src/__tests__/templating.test.ts | 18 + src/processTemplate.ts | 2 +- 4 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 src/__tests__/fixtures/insertArray.docx diff --git a/src/__tests__/__snapshots__/templating.test.ts.snap b/src/__tests__/__snapshots__/templating.test.ts.snap index 1bc94309..85618666 100644 --- a/src/__tests__/__snapshots__/templating.test.ts.snap +++ b/src/__tests__/__snapshots__/templating.test.ts.snap @@ -26644,6 +26644,230 @@ Object { } `; +exports[`noSandbox Template processing INS command is an array (see issue #214) 1`] = ` +Object { + "_attrs": Object { + "mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14", + "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", + "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", + "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", + "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", + "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", + "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", + "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", + "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", + "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", + "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", + "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", + "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", + "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", + "xmlns:o": "urn:schemas-microsoft-com:office:office", + "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + "xmlns:v": "urn:schemas-microsoft-com:vml", + "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + "xmlns:w10": "urn:schemas-microsoft-com:office:word", + "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", + "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", + "xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml", + "xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex", + "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", + "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", + "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", + "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", + "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", + "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", + "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", + "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", + "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w14:paraId": "3A705D94", + "w14:textId": "044CEA80", + "w:rsidP": "00C863B5", + "w:rsidR": "00C863B5", + "w:rsidRDefault": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w:val": "es-ES", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:lang", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pPr", + }, + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w:val": "es-ES", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:lang", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + Object { + "_attrs": Object { + "xml:space": "preserve", + }, + "_children": Array [ + Object { + "_children": Array [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "a,b,c", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + Object { + "_attrs": Object { + "w14:paraId": "743B5CEB", + "w14:textId": "6C1E73F1", + "w:rsidP": "00C863B5", + "w:rsidR": "00D310BE", + "w:rsidRDefault": "00FE460C", + "w:rsidRPr": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "xml:space": "preserve", + }, + "_children": Array [ + Object { + "_children": Array [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "1,2,3", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + Object { + "_attrs": Object { + "w:rsidR": "00D310BE", + "w:rsidRPr": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object { + "w:h": "15840", + "w:w": "12240", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgSz", + }, + Object { + "_attrs": Object { + "w:bottom": "1417", + "w:footer": "708", + "w:gutter": "0", + "w:header": "708", + "w:left": "1701", + "w:right": "1701", + "w:top": "1417", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgMar", + }, + Object { + "_attrs": Object { + "w:space": "708", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:cols", + }, + Object { + "_attrs": Object { + "w:linePitch": "360", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:docGrid", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:sectPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:body", + }, + ], + "_fTextNode": false, + "_tag": "w:document", +} +`; + exports[`noSandbox Template processing avoids confusion between variable name and built-in command 1`] = ` Object { "_attrs": Object { @@ -54842,6 +55066,230 @@ Object { } `; +exports[`sandbox Template processing INS command is an array (see issue #214) 1`] = ` +Object { + "_attrs": Object { + "mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14", + "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", + "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", + "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", + "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", + "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", + "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", + "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", + "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", + "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", + "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", + "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", + "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", + "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", + "xmlns:o": "urn:schemas-microsoft-com:office:office", + "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + "xmlns:v": "urn:schemas-microsoft-com:vml", + "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + "xmlns:w10": "urn:schemas-microsoft-com:office:word", + "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", + "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", + "xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml", + "xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex", + "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", + "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", + "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", + "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", + "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", + "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", + "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", + "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", + "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w14:paraId": "3A705D94", + "w14:textId": "044CEA80", + "w:rsidP": "00C863B5", + "w:rsidR": "00C863B5", + "w:rsidRDefault": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w:val": "es-ES", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:lang", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pPr", + }, + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "w:val": "es-ES", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:lang", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + Object { + "_attrs": Object { + "xml:space": "preserve", + }, + "_children": Array [ + Object { + "_children": Array [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "a,b,c", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + Object { + "_attrs": Object { + "w14:paraId": "743B5CEB", + "w14:textId": "6C1E73F1", + "w:rsidP": "00C863B5", + "w:rsidR": "00D310BE", + "w:rsidRDefault": "00FE460C", + "w:rsidRPr": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object {}, + "_children": Array [ + Object { + "_attrs": Object { + "xml:space": "preserve", + }, + "_children": Array [ + Object { + "_children": Array [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "1,2,3", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + Object { + "_attrs": Object { + "w:rsidR": "00D310BE", + "w:rsidRPr": "00C863B5", + }, + "_children": Array [ + Object { + "_attrs": Object { + "w:h": "15840", + "w:w": "12240", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgSz", + }, + Object { + "_attrs": Object { + "w:bottom": "1417", + "w:footer": "708", + "w:gutter": "0", + "w:header": "708", + "w:left": "1701", + "w:right": "1701", + "w:top": "1417", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgMar", + }, + Object { + "_attrs": Object { + "w:space": "708", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:cols", + }, + Object { + "_attrs": Object { + "w:linePitch": "360", + }, + "_children": Array [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:docGrid", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:sectPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:body", + }, + ], + "_fTextNode": false, + "_tag": "w:document", +} +`; + exports[`sandbox Template processing avoids confusion between variable name and built-in command 1`] = ` Object { "_attrs": Object { diff --git a/src/__tests__/fixtures/insertArray.docx b/src/__tests__/fixtures/insertArray.docx new file mode 100644 index 0000000000000000000000000000000000000000..ff81464797e46704911d2ffc4b8f9756d5a25fd7 GIT binary patch literal 12044 zcmeHNWm{ZHw{0M}ySoGp?gRak10VnZ07}4W?u4x_6aYX03jkmP5TNzM9qe5# z>|Kr2-#S{j7`*Vbv!%#>22Gy@fQHon@Adz<2Wk@s?Z2>LNM0q~qQ^C8nC@m5GeSoS zC$p&T!4r5xYd*yHfgjtjp;a`X;*e~qXgRM|I5m3%#~0FV5i#pLXb3V&gjB})2r zd-2Zh8U_G(dV&Ec|05*H;)oiKA%3O^i8y3PNE$g?*t)R3_<8?tDE>c=zrQuTG``cO ziw#BeIPf8Gyj5kPlORWt)og5$U>+VpPevYlan5G;@j+;A4%%SPL~3wiGGWZiB?IWT zmS}K7l&pao(TX^8W7ws42lfOc1%vb0J!c%hp?uiBw0sz#mSGqOjMTx67$t&>yADeo z?!ew+l(^g~K(?l07@abssmaN7(wMzUeaD%V#y&k`BdzBRU;I+CErhgrgzz1brASo@ zCrfP1mz8RRZuR|yMvf>Oh6`pQTQ*kOj5yO$B%%}W_`X+8dqGclFf-z3#BkO-A4`2K z-N&7XZ9);AV@jP`qjd-33BnCiN5JCXK}PM!UHtrU6A$F8Dkez;XTXfSwvRxT@2%m)|&%TMuIqF zJwrp=%rP59xv2|(iEKXAG4{~9L~{WWE(_r-Io7C{z-_KxO*lJ4w@Bxt9S;sgLgh@h zo^nkLj|=WF81{&ng8?} ziC};hF2rNnkO2Tph%@}=HGlV)+~ie<4{R8HtIv=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2D5>I4&pBF;!P((SPWRprzr78}2{Iq#U=P85A z_NXeJ*f52$^_+Vt$s{l2S?N^l`y{V5wE6JU6ryY}1Se9o{tb`O+V|{{f*-PKl~d({IQK$E z^sHy`^+Og7X{k5XR7`I1Di3M75`iX5y6BvGqq1G_Ma6Ue^kP3)H(%nI8`PkTjPSu%LG@}_g(+SHB(6&OUn0(ULQmCPv4KzK5RD#f6{1w+6IlvXFEdo4v(m_ z9>9n4_qNnPA9k-tEAbU|JL>IV{X} z0B@!68(=h+@|;Ib<`cGFDG_4VH8fnE?w;HhN4UL28hMAYG=3|27q~{EG^uupfjAl{ z_(r$o(8{N_YQ0OI!> z_>sjzFF_||L^^6Y;E`Om>Xzy0+~{BTT&DA9iyn|Y*AOJ>3*+x%l8K|^f3+k?m;G^N zsCLT2uw%3$KXz4ne6Wkl=7^Gxq<@Xuvd>Rb)6!{+6|cR}?oqEdi|eq>b*!*`xn65I<`4Z>6sIh*y@mkXj2#N!MyW7FsxtYcO~VG!8dA8E-I&BJ$9S1S;N*bQ63DtZ$8K zqtFwZ61(2swG*w3`?3~aeI}b4*6|KOyLkq=W#{T(dJr}3V>bBd7vStI4op%X2 zS;qq0#H=(osRq&1F+`P=c(@h>wkXe*#y>op?4K+xQ}JEBS=>#&p7B!@{-}f`5L)Kz zlIVNQeGl22{(e#e1e}Mr2L3{w;!sC$qf&WD` z`jz2V_2VxFKhi(j|G!$uui$@LsQ&|oc;vPQ}YLNk*kTI5<`RA|y E0ZQj!00000 literal 0 HcmV?d00001 diff --git a/src/__tests__/templating.test.ts b/src/__tests__/templating.test.ts index c0009368..ddfee624 100755 --- a/src/__tests__/templating.test.ts +++ b/src/__tests__/templating.test.ts @@ -1112,6 +1112,24 @@ Morbi dignissim consequat ex, non finibus est faucibus sodales. Integer sed just ); expect(result).toMatchSnapshot(); }); + + it('INS command is an array (see issue #214)', async () => { + const template = await fs.promises.readFile( + path.join(__dirname, 'fixtures', 'insertArray.docx') + ); + expect( + await createReport( + { + noSandbox, + template, + data: { + companies: ['a', 'b', 'c'], + }, + }, + 'JS' + ) + ).toMatchSnapshot(); + }); }); }); }); diff --git a/src/processTemplate.ts b/src/processTemplate.ts index 482dba55..903d644d 100755 --- a/src/processTemplate.ts +++ b/src/processTemplate.ts @@ -521,7 +521,7 @@ const processCmd: CommandProcessor = async ( if (result == null) { return ''; } - if (typeof result === 'object') { + if (typeof result === 'object' && !Array.isArray(result)) { const nerr = new ObjectCommandResultError(cmdRest); if (ctx.options.errorHandler != null) { result = await ctx.options.errorHandler(nerr, cmdRest);