Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename field does not support parenthesis #6

Closed
ruggertech opened this issue Feb 7, 2016 · 3 comments
Closed

Filename field does not support parenthesis #6

ruggertech opened this issue Feb 7, 2016 · 3 comments
Assignees
Labels

Comments

@ruggertech
Copy link

a file name may contain parenthesis, i.e: "myFile(1).jpg"
content-disposition does not support such file name.

@dougwilson dougwilson self-assigned this Feb 10, 2016
@dougwilson
Copy link
Contributor

Hi! Can you elaborate on your statement a bit? I can create a content disposition string with that file name just fine:

$ node -pe 'require("content-disposition")("myFile(1).jpg")'
attachment; filename="myFile(1).jpg"

@ruggertech
Copy link
Author

the following code:

var contentDisposition = require('content-disposition');
var dispo = "attachment; filename=Chime%20(1).dmg";
console.log(contentDisposition.parse(dispo).parameters.filename);

fails with the error:

/node_modules/content-disposition/index.js:369
throw new TypeError('invalid parameter format')
^
TypeError: invalid parameter format
at Function.parse (node_modules/content-disposition/index.js:369:11)
at Object. (disposition.js:4:32)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain as _onTimeout
at Timer.listOnTimeout as ontimeout

@dougwilson
Copy link
Contributor

Ah, I see. Yes, that error is because it's an invalid HTTP Content-Disposition header. The characters ( and ) cannot be used outside of a quoted string. In fact, unless your filename has %20 literally in it, it looks like you are actually trying to parse the Content-Disposition that is part of a multipart/form-data request, which does not follow the same specification as the HTTP version of this header.

The issue #3 is tracking getting support for parsing the Content-Disposition from a multipart request, which is so insane because the various different web browsers don't even act the same, so it's a very difficult task to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants