Open Pascal76 opened 5 months ago
Thanks for reporting @Pascal76!
Here's a sample showing how to use the customCode
option:
The customCode
option accepts either stringified JavaScript code or the name of the .js
file available locally.
You can take a look at the CLI examples as well: https://github.com/highcharts/node-export-server/blob/ced7b17b8e2188291ba90d5d56acc440f71024e1/tests/cli/scenarios/allow_code_execution_and_file_resources.json#L1-L8
Please try to follow this and let me know if it works for you. If not, please share the full log (--logLevel 4
). Try to include a console.log
statement in your customCode
as well, it will help us determine whether your function runs or not.
Thank you !
It works except for the border attribute (?!) while my JS file contains :
Highcharts.AST.allowedTags.push('table'); Highcharts.AST.allowedTags.push('tr'); Highcharts.AST.allowedTags.push('td'); Highcharts.AST.allowedTags.push('center'); Highcharts.AST.allowedTags.push('class'); Highcharts.AST.allowedTags.push('style'); Highcharts.AST.allowedAttributes.push('border'); Highcharts.AST.allowedAttributes.push('align'); Highcharts.AST.allowedAttributes.push('bordercolor'); Highcharts.AST.allowedAttributes.push('zIndex'); Highcharts.AST.allowedAttributes.push('bgcolor'); Highcharts.AST.allowedAttributes.push('cellpadding'); Highcharts.AST.allowedAttributes.push('cellspacing'); Highcharts.AST.allowedAttributes.push('center');
What is not working :
'name' : 'outlook
When I remove border=0 then it works.
That is indeed strange.
Could you please share the SVG that you're sending? Is there a way for me to replicate this locally?
also if the json file contains comments like // xx then it breaks the generation of the image ( / xx / format is OK )
Wed Jun 05 2024 12:28:02 GMT+0200 [error] - [pool] In pool.postWork: Error encountered during export: 6.174512ms.
SyntaxError: Unexpected token ')'
new Function (
@Pascal76 the JSON file cannot contain comments: https://stackoverflow.com/questions/244777/can-comments-be-used-in-json
If the provided JSON file is not proper, there will be an error (most likely) which would resemble the one that you've attached above.
Regarding the allowed tags & attributes, I will investigate why that happens.
Closing due to inactivity.
Summary:
Hello @jszuminski You closed this ticket... but did you check "Regarding the allowed tags & attributes, I will investigate why that happens." ?
I spoke about issue with border=0 Same issue with align="XXX" Even when AST.allowedAttributes.js (loaded by 'customCode' : './AST.allowedAttributes.js') contains : Highcharts.AST.allowedAttributes.push('align');
Hello,
How can I use Highcharts.AST.allowedAttributes with /usr/local/bin/highcharts-export-server (v4) please ?
I tryed using --customCode "AST.allowedAttributes.js" but it does not work.
The file contains: Highcharts.AST.allowedAttributes.push('border'); Highcharts.AST.allowedAttributes.push('align'); Highcharts.AST.allowedAttributes.push('bordercolor'); Highcharts.AST.allowedAttributes.push('zIndex'); Highcharts.AST.allowedAttributes.push('bgcolor'); Highcharts.AST.allowedAttributes.push('cellpadding'); Highcharts.AST.allowedAttributes.push('cellspacing'); Highcharts.AST.allowedTags.push('center'); Highcharts.AST.allowedAttributes.push('center');
On the Dockerfile: WORKDIR /node-export-server ADD ["AST.allowedAttributes.js","/node-export-server"] RUN chown -R node /node-export-server && \ chmod 644 AST.allowedAttributes.js
The command line : /bin/docker run -u 0:0 -v /apache_sites/jbm:/apache_sites/jbm --rm --tmpfs=/run highcharts_es timeout 10 /usr/local/bin/highcharts-export-server --allowCodeExecution true --infile /apache_sites/jbm/b.json --outfile /apache_sites/jbm/web/img/toto.png --resources '[]' --customCode AST.allowedAttributes.js --width 720 --height 320 --scale 1.2 --logLevel 4