Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: felixge/node-formidable
base: v0.9.0
...
head fork: felixge/node-formidable
compare: v0.9.1
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 16, 2010
@felixge Fix: Handle resume errors c9df5fe
@felixge Fix: Don't let the world know how stupid IE is
IE6 (and up?) actually sends the full path of the local file that is
being uploaded rather than just the name of it. This patch strips of
any path information from the filename.
0358f0e
@felixge Bump version cd5686b
View
10 lib/formidable/incoming_form.js
@@ -36,7 +36,13 @@ IncomingForm.prototype.parse = function(req, cb) {
};
this.resume = function() {
- req.resume();
+ try {
+ req.resume();
+ } catch (err) {
+ this._error(err);
+ return false;
+ }
+
return true;
};
@@ -239,7 +245,7 @@ IncomingForm.prototype._initMultipart = function(boundary) {
}
if (m = headerValue.match(/filename="([^"]+)"/i)) {
- part.filename = m[1];
+ part.filename = m[1].substr(m[1].lastIndexOf('\\') + 1);
}
} else if (headerField == 'content-type') {
part.mime = headerValue;
View
2  package.json
@@ -1,5 +1,5 @@
{ "name" : "formidable"
-, "version": "0.9.0"
+, "version": "0.9.1"
, "dependencies": {"gently": ">=0.7.0"}
, "directories" : { "lib" : "./lib/formidable" }
, "main" : "./lib/formidable/index"
View
19 test/simple/test-incoming-form.js
@@ -63,6 +63,19 @@ test(function parse() {
gently.expect(REQ, 'resume');
assert.strictEqual(form.resume(), true);
})();
+
+ (function testResumeException() {
+ var ERR = new Error('dasdsa');
+ gently.expect(REQ, 'resume', function() {
+ throw ERR;
+ });
+
+ gently.expect(form, '_error', function(err) {
+ assert.strictEqual(err, ERR);
+ });
+
+ assert.strictEqual(form.resume(), false);
+ })();
(function testEmitError() {
var ERR = new Error('something bad happened');
@@ -365,12 +378,12 @@ test(function _initMultipart() {
gently.expect(form, 'onPart', function(part) {
assert.deepEqual
( part.headers
- , { 'content-disposition': 'form-data; name="field2"; filename="file1.txt"'
+ , { 'content-disposition': 'form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sunset.jpg"'
, 'content-type': 'text/plain'
}
);
assert.equal(part.name, 'field2');
- assert.equal(part.filename, 'file1.txt');
+ assert.equal(part.filename, 'Sunset.jpg');
assert.equal(part.mime, 'text/plain');
gently.expect(part, 'emit', function(event, b) {
@@ -385,7 +398,7 @@ test(function _initMultipart() {
PARSER.onPartBegin();
PARSER.onHeaderField(new Buffer('content-disposition'), 0, 19);
- PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="file1.txt"'), 0, 46);
+ PARSER.onHeaderValue(new Buffer('form-data; name="field2"; filename="C:\\Documents and Settings\\IE\\Must\\Die\\Sunset.jpg"'), 0, 85);
PARSER.onHeaderField(new Buffer('Content-Type'), 0, 12);
PARSER.onHeaderValue(new Buffer('text/plain'), 0, 10);
PARSER.onPartData(new Buffer('... contents of file1.txt ...'), 0, 29);

No commit comments for this range

Something went wrong with that request. Please try again.