Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-1632

Epilogue area in MIME multipart_related docs is not ignored

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.2
    • 1.4.0
    • HTTP Interface
    • 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,[

      {file,"/Users/hs/prj/build-couchdb/dependencies/couchdb/src/couchdb/couch_doc.erl"}

      ,

      {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

      Attachments

        Activity

          People

            Unassigned Unassigned
            pek Peter Keller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: