Permalink
Browse files

Fixed handling of multipart/mixed parts produced by Opera 11.01 with …

…HTML input "type=file multiple" according to rfc1341.
  • Loading branch information...
1 parent 762f129 commit f4f54a554c1205c41460c2df92b43582e4baffe8 @furagu committed Jun 6, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/parse.js
View
@@ -181,11 +181,20 @@ Parser.prototype.write = function (chunk) {
// message end.
// parent ends, look for a new part in the grandparent.
parser.part = parser.part.parent;
+ var ended_part = parser.part;
if (parser.part !== parser)
emit(parser, "onPartEnd", parser.part);
parser.part = parser.part.parent;
parser.state = S.NEW_PART;
- parser.buffer = parser.buffer.substr(boundary.length + 4);
+ if (ended_part.isMultiPart) {
+ // skip the multipart epilogue
+ var epilogue_end = parser.buffer.indexOf(parser.part.boundary);
+ if (epilogue_end !== false) {
+ parser.buffer = parser.buffer.substr(epilogue_end);
+ }
+ } else {
+ parser.buffer = parser.buffer.substr(boundary.length + 4);
+ }
} else {
// another part coming for the parent message.
parser.part = parser.part.parent;

0 comments on commit f4f54a5

Please sign in to comment.