carboneio / carbone

Fast and simple report generator, from JSON to pdf, xslx, docx, odt...
https://carbone.io
Other
1.3k stars 190 forks source link

[Bug Report]: Exception when passed invalid data to carbone render method #125

Closed Satya-vurapalli closed 3 years ago

Satya-vurapalli commented 3 years ago

Environment Carbone Version: 3.1.0 Node Version: v10.16.0 Browsers: [e.g. chrome 22]

Expected Behaviour Render method must return an error when the passed *.docx file is corrupted or some invalid data.

Actual Behaviour Getting error in parser.js file and node server is stopped.

Steps to reproduce In the given in example in https://carbone.io/documentation.html#getting-started-with-carbone-js just pass some corrupted *.docx file. image

In our application we are running carbone API in node server. As per the example we are able to generate pdf by passing some sample template. In real time we are passing some random .docx files to render method. In one of the scenario we may get some corrupted or some invalid .docx file. In this case we are getting the below error.

\node_modules\carbone\lib\parser.js:297 var _regex = new RegExp('\$'+_variable+'(?!\w)(?:\(([\s\S]+?)\))?', 'g'); ^

SyntaxError: Invalid regular expression:

Screenshots If applicable, add screenshots to help explain your problem.

Reproduction Link / Code example image

Other comments Please help regarding this issue as it is stopping the node server.

steevepay commented 3 years ago

Hello @Satya-vurapalli,

Can you provide a DOCX template to reproduce the issue? everything is working well on my side.

Thank you

steevepay commented 3 years ago

I close the issue, if you are still getting the error, feel free to reopen with an example (a DOCX template + a JSON dataset)