Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix: node > 0.1.98 compatibility

  • Loading branch information...
commit 37e00ac66f93d2baadd2c99ace5be223348ec638 1 parent a12f8a9
@felixge authored
Showing with 3 additions and 14 deletions.
  1. +3 −14 lib/formidable/incoming_form.js
View
17 lib/formidable/incoming_form.js
@@ -5,7 +5,7 @@ var sys = require('sys')
, WriteStream = require('fs').WriteStream
, MultipartParser = require('./multipart_parser').MultipartParser
, QuerystringParser = require('./querystring_parser').QuerystringParser
- , Utf8Decoder = require('utf8decoder').Utf8Decoder
+ , StringDecoder = require('string_decoder').StringDecoder
, EventEmitter = require('events').EventEmitter;
function IncomingForm() {
@@ -130,21 +130,10 @@ IncomingForm.prototype.handlePart = function(part) {
if (!part.filename) {
var value = ''
- , decoder;
-
- if (this.encoding.toLowerCase() == 'utf-8') {
- decoder = new Utf8Decoder();
- decoder.onString = function(str) {
- value += str;
- };
- }
+ , decoder = new StringDecoder(this.encoding);
part.addListener('data', function(buffer) {
- if (decoder) {
- decoder.write(buffer);
- } else {
- value += buffer.toString(self.encoding);
- }
+ value += decoder.write(buffer);
});
part.addListener('end', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.