chjj / parted

Streaming body parser for node.js.
MIT License
63 stars 14 forks source link

Jumbled fields if form fields left blank? #2

Closed codedmart closed 13 years ago

codedmart commented 13 years ago

If I fill in all the fields I get this when I console log req.body which is correct:

{ _csrf: 'Nv6RqABrHOQfLxoGVBYrHz2r',
company_name: 'Zac Scott Homes',
broker: 'Coldwell Banker',
address: '1111 Northwest Blvd',
city: 'Coeur D\' Alene',
state: 'ID',
zip: '83814',
phone: '(509) 555-5555',
fax: '(208) 555-5555',
subdomain: 'domain',
personal_domain: 'domain.local,www.domain.local',
commit: 'SUBMIT >>',
broker_logo: 'tmp/Freahbooks.1319848442404.png',
personal_logo: 'tmp/Freshbooks.1319848442404.jpg' }

If I have some form fields blank then I get improper data (I left company_name, broker, address, broker_logo, and personal_logo blank):

{ _csrf: 'Nv6RqABrHOQfLxoGVBYrHz2r',
company_name: '\r\n------WebKitFormBoundary6SU4gAdLvhxvTsKL\r\nContent-Disposition: form-data; name="broker"\r\n\r\n',
address: '\r\n------WebKitFormBoundary6SU4gAdLvhxvTsKL\r\nContent-Disposition: form-data; name="city"\r\n\r\nCoeur D\' Alene',
state: 'ID',
zip: '83814',
phone: '(509) 555-5555',
fax: '(208) 555-5555',
subdomain: 'domain',
personal_domain: 'domain.local,www.domain.local',
broker_logo: '\r\n------WebKitFormBoundary6SU4gAdLvhxvTsKL\r\nContent-Disposition: form-data; name="personal_logo"; filename=""\r\nContent-Type: application/octet-stream\r\n\r\n',
commit: 'SUBMIT >>' }
chjj commented 13 years ago

That is a bug, and something I regrettably didn't think to test for.

Just fixed: 1b4816010d95910e00f590fac95c5e42838888df

It was a small arithmetic problem. (A single line where i = 0 needed to be i = -1). I'm pushing an immediate NPM update. Thanks a lot for pointing this out.

codedmart commented 13 years ago

Awesome! Thanks for the plugin!