jdavidbakr / mail-tracker

Package for Laravel to inject tracking code into outgoing emails.
MIT License
577 stars 129 forks source link

getHeader() method of SentEmail model will mangle header values that contain colons (specifically JSON data) #116

Closed ericlucit closed 4 years ago

ericlucit commented 4 years ago

I have a header attached to an email formatted as such

X-MyHeader : {"some_id":2,"some_othger_id":"0dd75231-31bb-4e67-8ab7-a83315f75a44","some_field":"A Field Value"}

When using the getHeader("X-MyHeader") - I receive only {"some_id"

Accoding to the RFC for Email Headers RFC 822, Section 3.1.2 :

The field-body may be composed of any ASCII characters, except CR or LF.

I think the issue is in the following line of code:

list($key, $value) = explode(":", $header.":");

Which could be changed to

list($key, $value) = explode(":", $header.":", 2);

which would limit the array to the first colon found

jdavidbakr commented 4 years ago

Thanks for the report! Fixed in version 4.0.9

ericlucit commented 4 years ago

Thanks! - Worked perfect