Do not ignore Content-Transfer-Encoding for multipart POST #128

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

A part of a multipart POST field may have its own encoding. This commit uses that, if present, before defaulting to IncomingForm.encoding.

Owner

felixge commented Jan 27, 2012

Needs a test. What kind of encoding do your parts have? If it's ascii, then decoding it as utf-8 shouldn't do any harm. If it's something else, the string_decoder module won't be able to handle it.

I am afraid that I cannot run the tests at all here.

After installing gently, urun and hashish, npm install findit fails with:
npm ERR! Error: Using '<' with 0.1.x makes no sense. Don't do it.
npm ERR! at /usr/share/npm/lib/utils/semver.js:94:29
npm ERR! at String.replace (native)
npm ERR! at replaceXRange (/usr/share/npm/lib/utils/semver.js:88:25)
npm ERR! at Array.map (native)
npm ERR! at replaceXRanges (/usr/share/npm/lib/utils/semver.js:84:17)
npm ERR! at Array.map (native)
npm ERR! at toComparators (/usr/share/npm/lib/utils/semver.js:66:8)
npm ERR! at Object.validRange
(/usr/share/npm/lib/utils/semver.js:138:11)
npm ERR! at install_ (/usr/share/npm/lib/install.js:103:22)
npm ERR! at /usr/share/npm/lib/install.js:77:5
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to npm-@googlegroups.com
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

I removed the statement at /usr/share/npm/lib/utils/semver.js:94:29 and got
this:
npm ERR! Error: No satisfying version found for 'hashish'@'>=0.0.2 >=0.1.0
<0.2.0'
npm ERR! Valid install targets for hashish: "latest", "0.0.1", "0.0.2",
"0.0.3", "0.0.4"
npm ERR! at /usr/share/npm/lib/install.js:146:29
npm ERR! at /usr/share/npm/lib/install.js:181:5
npm ERR! at /usr/share/npm/lib/utils/registry/get.js:55:5
npm ERR! at /usr/share/npm/lib/utils/registry/request.js:36:10
npm ERR! at IncomingMessage.
(/usr/share/npm/lib/utils/registry/request.js:173:14)
npm ERR! at IncomingMessage.emit (events.js:81:20)
npm ERR! at HTTPParser.onMessageComplete (http.js:133:23)
npm ERR! at Client.onData as ondata
npm ERR! at Client._onReadable (net.js:683:27)
npm ERR! at IOWatcher.onReadable as callback
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to npm-@googlegroups.com
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

Where would I add the test? I need to mock parsing a request where the
encoding is set differently for different parts, and especially where one
part is binary and the entire request is set to UTF-8, and the binary data
contains characters that may be interpreted as UTF-8 special characters.

2012/1/27 Felix Geisendörfer <
reply@reply.github.com

Needs a test. What kind of encoding do your parts have? If it's ascii,
then decoding it as utf-8 shouldn't do any harm. If it's something else,
the string_decoder module won't be able to handle it.


Reply to this email directly or view it on GitHub:
#128 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment