- Issue created by @diptib
- 🇮🇳India digitalapicraft
Url not encoded breaks images in mail
diff --git a/src/Utility/MimeMailFormatHelper.php b/src/Utility/MimeMailFormatHelper.php index ea6b31f..c46e367 100644 --- a/src/Utility/MimeMailFormatHelper.php +++ b/src/Utility/MimeMailFormatHelper.php @@ -417,6 +417,8 @@ class MimeMailFormatHelper { } else { $url = static::mimeMailUrl($url, TRUE); + $url = preg_replace('/\s/','%20', $url); + $url = str_replace('+', '%20', $url); $scheme = StreamWrapperManager::getScheme($url); if ($scheme === 'http' || $scheme === 'https' || $scheme === 'data' || preg_match('/^(mailto):/', $url)) { // If $url holds an absolute URL for web-accessible content, or if it
- 🇺🇸United States tr Cascadia
- Please provide steps to reproduce and demonstrate the error. This is necessary so we can reproduce it and so we can write tests to prove the fix. I suggest using the mimemail_example module and describing how you had to set that up to cause the error, so that anyone can do the same thing on their site to see what the problem is. In fact, if you can write the test yourself that would be the most help - write a test case that produces the wrong result, to demonstrate the problem.
- Your patch does not urlencode the URL. It just changes a few characters at most - there is more to urlencoding than that. And the str_replace() is wrong - plus signs are used instead of spaces in urlencoding, not the other way around. What's wrong with the urlencode() function? Why does it have to be done at this point in the code - isn't mimeMailUrl() a better place?