Skip to content

Missing final CRLF in MIME content #207

Description

@tisdall

I'm doing iMIP processing and noticed that my icalendar content was missing a final CRLF. I haven't dug into this, but I'm assuming it's related to Mail.Parsers.RFC2822.

Here's an example:

rendered_email =
  ~S"""
  MIME-Version: 1.0
  Sender: Google Calendar <calendar-notification@google.com>
  Message-ID: <calendar-123123@google.com>
  Date: Tue, 04 Jun 2024 14:10:10 +0000
  Subject: ICS example
  From: test <test@example.com>
  To: organizer <organizer@example.com>
  Content-Type: multipart/mixed; boundary="000000000000f9fb19061a110156"

  --000000000000f9fb19061a110156
  Content-Type: text/calendar; charset="UTF-8"; method=REPLY
  Content-Transfer-Encoding: 7bit

  BEGIN:VCALENDAR
  PRODID:-//Google Inc//Google Calendar 70.9054//EN
  VERSION:2.0
  CALSCALE:GREGORIAN
  METHOD:REPLY
  BEGIN:VEVENT
  DTSTART:20240610T120000Z
  DTEND:20240610T130000Z
  DTSTAMP:20240604T141010Z
  ORGANIZER;CN=organizer:mailto:organizer@example.com
  UID:123
  ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=test;X
   -NUM-GUESTS=0:mailto:test@example.com
  CREATED:20240604T140456Z
  DESCRIPTION:
  LAST-MODIFIED:20240604T141009Z
  LOCATION:
  SEQUENCE:0
  STATUS:CONFIRMED
  SUMMARY:Google response
  TRANSP:OPAQUE
  END:VEVENT
  END:VCALENDAR

  --000000000000f9fb19061a110156--

  """
  |> String.replace("\n", "\r\n")

Mail.parse(rendered_email)
|> Map.get(:parts)
|> List.first()
|> Map.get(:body)
|> IO.inspect()

Trailing end of output: END:VEVENT\r\nEND:VCALENDAR"

I would have expected the output to end with a \r\n. I noticed this because my icalendar parser is expecting CRLF at the end of every line, so the last line missing it makes it invalid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions