natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 214 forks source link

Content-Disposition header value has incorrect syntax #311

Open wombat86 opened 4 years ago

wombat86 commented 4 years ago

Describe the bug When piping a Workbook to HTTP response, Content-Disposition header is set to a string with trailing ";" e.g: attachment; filename="report.xlsx"; filename*=utf-8''report.xlsx;

According to RFC 2183, the syntax of Content-Disposition header does not imply having a ";" character at the end of the header value. This issue was discovered while passing header value to content-disposition's parse() function which was throwing an error about invalid parameter format

To Reproduce

  1. Run the following server code snippet with NodeJS
    const express = require('express');
    const xl = require('excel4node');
    const app = express();
    app.get('/', function(req, res) {
    const wb = new xl.Workbook();
    wb.addWorksheet('Sheet1');
    wb.write('report.xlsx', res);
    });
    app.listen(3000, function() {
    console.log('Example app listening on port 3000!');
    });
  2. Send GET request to http://localhost:3000 with Postman or similar app.
  3. Observer Content-Disposition response header value.

Expected behavior A Content-Disposition header should contain syntactically correct value w/o trailing ";"

Environment

BruneXX commented 3 years ago

Hi Guys, can you take a look at this issue?