kumomta icon indicating copy to clipboard operation
kumomta copied to clipboard

detect and either error out or fixup trying to use newlines in headers in the http injection api

Open wez opened this issue 1 year ago • 0 comments

We had a user report issues when trying to do this:

{
  "envelope_sender": "ok@example",
  "content": {
    "subject": "hello\n\nHello there",
    "html_body": "<html>This is the HTML content of the message</html>",
    "text_body": "This is the Text content of the message",
    "from": {
      "email": "[email protected]",
      "name": "Test"
    },
    "headers": {
      "X-Tenant": "tenant"
    }
  },
  "recipients": [
    {
      "email": "[email protected]"
    }
  ]
}

the newlines in the subject caused the message body to start in the wrong place and caused issues with the tenant header seemingly not being present.

We should either raise an error for this case, or automatically fixup the newlines in the input so that the header value cannot escape and break the message.

Whichever we choose, we should apply it both to the subject header and any other arbitrary headers that are being passed into the builder.

wez avatar Sep 27 '24 18:09 wez