From 2fe9564a65a6db6d132f0fa49de3e29463c53c8d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 5 Feb 2020 12:20:42 +0100 Subject: Deal with long lines in mail headers --- mail.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mail.php b/mail.php index ba11244..1092b91 100644 --- a/mail.php +++ b/mail.php @@ -146,6 +146,7 @@ function mail_parse_message ($body,$prefill_info=[]) $info[$key]=$val; $lines=explode ("\n",$body); + $headers=[]; $i=0; foreach ($lines as $line){ $i++; @@ -153,8 +154,15 @@ function mail_parse_message ($body,$prefill_info=[]) break; $parts=explode (':',$line,2); - $key=trim ($parts[0]); - $val=trim ($parts[1]); + if (count ($parts) > 1) + $headers[]=['key' => trim ($parts[0]), 'val' => trim ($parts[1])]; + else + $headers[count ($headers)-1]['val'].=' '.trim ($line); + } + + foreach ($headers as $header){ + $key=$header['key']; + $val=$header['val']; if (levenshtein ($key,'Title') < 2) $info['title']=$val; -- cgit v1.2.3