Merge pull request #894 from mexon/mat/mailstream-url-params

[mailstream] Remove URL parameters when extracting image filenames
This commit is contained in:
Hypolite Petovan 2019-09-28 04:37:34 -04:00 committed by GitHub
commit a34110c60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -164,12 +164,13 @@ function mailstream_do_images($a, &$item, &$attachments) {
preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1); preg_match_all("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", $item["body"], $matches1);
preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2); preg_match_all("/\[img\](.*?)\[\/img\]/ism", $item["body"], $matches2);
foreach (array_merge($matches1[3], $matches2[1]) as $url) { foreach (array_merge($matches1[3], $matches2[1]) as $url) {
$components = parse_url($url);
$cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-'); $cookiejar = tempnam(get_temppath(), 'cookiejar-mailstream-');
$curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar); $curlResult = Network::fetchUrlFull($url, true, 0, '', $cookiejar);
$attachments[$url] = [ $attachments[$url] = [
'data' => $curlResult->getBody(), 'data' => $curlResult->getBody(),
'guid' => hash("crc32", $url), 'guid' => hash("crc32", $url),
'filename' => basename($url), 'filename' => basename($components['path']),
'type' => $curlResult->getContentType() 'type' => $curlResult->getContentType()
]; ];