From db6d5dd85a11043ab8a09087c6c0ebdd6e02ea66 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Sun, 29 Sep 2019 22:07:11 +0200 Subject: [PATCH 1/2] [mailstream] Support new img format with alt text --- mailstream/mailstream.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 32d021382..563dd9061 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -163,7 +163,8 @@ function mailstream_do_images($a, &$item, &$attachments) { $attachments = []; preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1); preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2); - foreach (array_merge($matches1[3], $matches2[1]) as $url) { + preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3); + foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) { $components = parse_url($url); $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); $curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar); From 801b88a9820a9999a6db91a26656ff757a9e0406 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Sun, 29 Sep 2019 22:22:52 +0200 Subject: [PATCH 2/2] [mailstream] Check for malformed image URLs and do not attempt to attach them --- mailstream/mailstream.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 563dd9061..a58dfc1cd 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -166,6 +166,9 @@ function mailstream_do_images($a, &$item, &$attachments) { preg_match_all("/\[img\=([^\]]*)\]([^[]*)\[\/img\]/ism", $item["body"], $matches3); foreach (array_merge($matches1[3], $matches2[1], $matches3[1]) as $url) { $components = parse_url($url); + if (!$components) { + continue; + } $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); $curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar); $attachments[$url] = [