node-export-server icon indicating copy to clipboard operation
node-export-server copied to clipboard

Escaped quotes, e.g in formatters, break export

Open paukert opened this issue 9 months ago • 0 comments

Export server version: v5.0.0 Highcharts version: 10.2.1

The only difference between these examples is in used quotes in labelFormatter. Only the first one works with export server.

{
  "infile": {
    "exporting": {
      "enabled": true
    },
    "xAxis": {
      "type": "datetime"
    },
    "legend": {
      "labelFormatter": "function () { if (typeof this.chart.series[0] !== 'undefined') { return this.chart.series[0].name; } return 'Somethign else';}"
    },
    "series": [
      {
        "name": "Temperature",
        "data": [
          {
            "x": 1743214500000,
            "y": 1
          }
        ]
      }
    ]
  }
}
{
  "infile": {
    "exporting": {
      "enabled": true
    },
    "xAxis": {
      "type": "datetime"
    },
    "legend": {
      "labelFormatter": "function () { if (typeof this.chart.series[0] !== \"undefined\") { return this.chart.series[0].name; } return 'Somethign else';}"
    },
    "series": [
      {
        "name": "Temperature",
        "data": [
          {
            "x": 1743214500000,
            "y": 1
          }
        ]
      }
    ]
  }
}

Export server logs and received response from export server for the second example:

{
  "statusCode": 400,
  "message": "[pool] In pool.postWork: For request with ID 935e61e6ae0f4356a2a2264867c6f423 - Error encountered during export: 8.110875ms."
}
2025-04-05 13:29:27 Sat Apr 05 2025 11:29:27 GMT+0000 [error] - [pool] In pool.postWork: For request with ID 935e61e6ae0f4356a2a2264867c6f423 - Error encountered during export: 8.110875ms. 
2025-04-05 13:29:27  SyntaxError: Invalid or unexpected token
2025-04-05 13:29:27 new Function (<anonymous>)
2025-04-05 13:29:27     at triggerExport (evaluate at setAsConfig (file:///home/pptruser/node_modules/highcharts-export-server/lib/export.js:157:15), <anonymous>:63:6)
2025-04-05 13:29:27     at #evaluate (file:///home/pptruser/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ExecutionContext.js:383:19)
2025-04-05 13:29:27     at async ExecutionContext.evaluate (file:///home/pptruser/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/ExecutionContext.js:270:16)
2025-04-05 13:29:27     at async IsolatedWorld.evaluate (file:///home/pptruser/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/IsolatedWorld.js:96:16)
2025-04-05 13:29:27     at async CdpFrame.evaluate (file:///home/pptruser/node_modules/puppeteer-core/lib/esm/puppeteer/api/Frame.js:335:20)
2025-04-05 13:29:27     at async CdpPage.evaluate (file:///home/pptruser/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:799:20)
2025-04-05 13:29:27     at async default (file:///home/pptruser/node_modules/highcharts-export-server/lib/export.js:208:9)
2025-04-05 13:29:27     at async postWork (file:///home/pptruser/node_modules/highcharts-export-server/lib/pool.js:328:20)
2025-04-05 13:29:27     at async doExport (file:///home/pptruser/node_modules/highcharts-export-server/lib/chart.js:438:20)
2025-04-05 13:29:27     at async exportHandler (file:///home/pptruser/node_modules/highcharts-export-server/lib/server/routes/export.js:225:5)

paukert avatar Apr 05 '25 11:04 paukert