GithubHelp home page GithubHelp logo

Comments (3)

dougwilson avatar dougwilson commented on July 21, 2024

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"

from content-disposition.

ruggertech avatar ruggertech commented on July 21, 2024

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

from content-disposition.

dougwilson avatar dougwilson commented on July 21, 2024

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.

from content-disposition.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.