Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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.9
...
head fork: felixge/node-formidable
compare: v0.9.10
Checking mergeability… Don't worry, you can still create the pull request.
  • 8 commits
  • 6 files changed
  • 4 commit comments
  • 3 contributors
Commits on Oct 24, 2010
@felixge Fix comma error introduced in refactoring df18901
Commits on Oct 30, 2010
@felixge Better project description
Also added a paragraph about the state of the module with a tiny advertisment for
transloadit ; ).
0cba820
Commits on Nov 12, 2010
@felixge Fix global variable leak
See report here: 792503a#L0R252
82050b7
Commits on Nov 25, 2010
@felixge Make Makefile more portable 66fbaae
Commits on Dec 07, 2010
@aheckmann aheckmann fix global var leaks (comma last issue) 8e6cb2e
Commits on Dec 15, 2010
@ncr ncr Remove parsing of optional CRLF epilogoue, change parser so it ignore…
…s everything after last boundary
4800b7f
@felixge Bringing back the old rfc1867 test
The test without the trailing \r\n is now a separate test.
633f0b5
@felixge Bump version 2b02144
View
4 Makefile
@@ -1,7 +1,9 @@
+SHELL := /bin/bash
+
test:
@find test/{simple,integration,system}/test-*.js | xargs -n 1 -t node
clean:
rm test/tmp/*
-.PHONY: test clean
+.PHONY: test clean
View
11 Readme.md
@@ -2,7 +2,13 @@
## Purpose
-A node.js module for dealing with web forms.
+A node.js module for parsing form data, especially file uploads.
+
+## Current status
+
+This module was developed for [Transloadit](http://transloadit.com/), a service focused on uploading
+and encoding images and videos. It has been battle-tested against hundreds of GB of file uploads from
+a big variety of clients and is considered production-ready.
## Features
@@ -35,7 +41,8 @@ Note: Formidable requires [gently](http://github.com/felixge/node-gently) to run
Parse an incoming file upload.
var formidable = require('formidable'),
- http = require('http')
+ http = require('http'),
+
sys = require('sys');
http.createServer(function(req, res) {
View
4 lib/formidable/incoming_form.js
@@ -1,6 +1,6 @@
if (global.GENTLY) require = GENTLY.hijack(require);
-var util = require('./util')
+var util = require('./util'),
path = require('path'),
File = require('./file'),
MultipartParser = require('./multipart_parser').MultipartParser,
@@ -326,7 +326,7 @@ IncomingForm.prototype._initUrlencoded = function() {
IncomingForm.prototype._uploadPath = function(filename) {
var name = '';
- for (i = 0; i < 32; i++) {
+ for (var i = 0; i < 32; i++) {
name += Math.floor(Math.random() * 16).toString(16);
}
View
22 lib/formidable/multipart_parser.js
@@ -1,4 +1,4 @@
-var Buffer = require('buffer').Buffer
+var Buffer = require('buffer').Buffer,
s = 0,
S =
{ PARSER_UNINITIALIZED: s++,
@@ -250,27 +250,15 @@ MultipartParser.prototype.write = function(buffer) {
}
} else if (flags & F.LAST_BOUNDARY) {
if (c == HYPHEN) {
- index++;
+ callback('partEnd');
+ callback('end');
+ state = S.END;
} else {
index = 0;
}
} else {
index = 0;
}
- } else if (index - 2 == boundary.length) {
- if (c == CR) {
- index++;
- } else {
- index = 0;
- }
- } else if (index - boundary.length == 3) {
- index = 0;
- if (c == LF) {
- callback('partEnd');
- callback('end');
- state = S.END;
- break;
- }
}
if (index > 0) {
@@ -290,6 +278,8 @@ MultipartParser.prototype.write = function(buffer) {
}
break;
+ case S.END:
+ break;
default:
return i;
}
View
4 package.json
@@ -1,6 +1,6 @@
{ "name" : "formidable",
- "version": "0.9.9",
+ "version": "0.9.10",
"dependencies": {"gently": ">=0.7.0"},
"directories" : { "lib" : "./lib/formidable" },
- "main" : "./lib/formidable/index",
+ "main" : "./lib/formidable/index"
}
View
28 test/fixture/multipart.js
@@ -26,6 +26,34 @@ exports['rfc1867'] =
]
};
+exports['noTrailing\r\n'] =
+ { boundary: 'AaB03x',
+ raw:
+ '--AaB03x\r\n'+
+ 'content-disposition: form-data; name="field1"\r\n'+
+ '\r\n'+
+ 'Joe Blow\r\nalmost tricked you!\r\n'+
+ '--AaB03x\r\n'+
+ 'content-disposition: form-data; name="pics"; filename="file1.txt"\r\n'+
+ 'Content-Type: text/plain\r\n'+
+ '\r\n'+
+ '... contents of file1.txt ...\r\r\n'+
+ '--AaB03x--',
+ parts:
+ [ { headers: {
+ 'content-disposition': 'form-data; name="field1"',
+ },
+ data: 'Joe Blow\r\nalmost tricked you!',
+ },
+ { headers: {
+ 'content-disposition': 'form-data; name="pics"; filename="file1.txt"',
+ 'Content-Type': 'text/plain',
+ },
+ data: '... contents of file1.txt ...\r',
+ }
+ ]
+ };
+
exports['emptyHeader'] =
{ boundary: 'AaB03x',
raw:

Showing you all comments on commits in this comparison.

@aheckmann

Comma first! :p

@felixge
Owner

Well, JSON is fucking stupid for not allowing a trailing comma. But since V8 doesn't care for JavaScript itself it's usually not a problem.

Anyway - I agree, comma-first was nice, but since nobody else seems to embrace it I'd rather go with an accepted convention for my modules.

@aheckmann

Twice in the past two weeks I've been bitten by this exact issue in older code. Yeah, it'd be great if more people began using it. I'm glad I've switched.

@aheckmann

whoop!

Something went wrong with that request. Please try again.