Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.2
-
None
Description
When PUTting a document with attachments in MIME multipart/related format, CouchDB (1.2.0 on Mac OS X) throws a badmatch error in doc_from_multi_part_stream() if any bytes are following the final boundary.
For example, if the last body part ends with
\r\n==1234==\r\nabc
the error reads
[error] [emulator] Error in process <0.18266.with exit value: badmatch,{<<7 bytes>>, #Fun<couch_httpd_db.23.117176975>,ok,[{couch_doc,'doc_from_multi_part_stream/2-fun-1',3,[
,
{line,512}]}]}
where <<7 bytes>> is 2 + the number of bytes following the two ending hyphens (5 in this example). Everything works fine if the last body part ends with two hyphens only (i.e. the epilogue is left blank).
However, according to RFC 1521 Sec. 7.2.1 (<http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html>), "implementations should ignore anything that appears before the first boundary or after the last one".
--Peter
Confirmations:
On 18.12.201, 18:48 Jens Alfke <jens@couchbase.com>:
> When PUTting a document with attachments in MIME multipart/related format, CouchDB (1.2.0 on Mac
> OS X) throws a badmatch error in doc_from_multi_part_stream() if any bytes are following the final boundary.
Confirmed; I ran into this as well, while implementing TouchDB, but was too lazy to file a bug report. Don’t repeat my mistake!
Judging by activity on some other bugs I did report, the multipart code is being cleaned up for 1.3, so maybe they can get to this too.
—Jens