Replaces spaces in image URLs
This commit is contained in:
@@ -130,6 +130,10 @@ class Renderer {
|
||||
|
||||
function postProcessTemplate($template) {
|
||||
$DOM = $this->DOM_parser->parseStr($template);
|
||||
// replace spaces in image tag URLs
|
||||
foreach($DOM->query('img') as $image) {
|
||||
$image->src = str_replace(' ', '%20', $image->src);
|
||||
}
|
||||
$template = $DOM->query('.mailpoet_template');
|
||||
// replace all !important tags except for in the body tag
|
||||
$template->html(
|
||||
|
@@ -191,7 +191,7 @@ class RendererTest extends \MailPoetTest {
|
||||
);
|
||||
$rendered_image = Image::render($image, $columnCount = 1);
|
||||
expect($rendered_image)->contains('src="//path-without-protocol"');
|
||||
}
|
||||
}
|
||||
|
||||
function testItRendersImageWithLink() {
|
||||
$newsletter = $this->newsletter['body'];
|
||||
@@ -444,11 +444,12 @@ class RendererTest extends \MailPoetTest {
|
||||
function testItPostProcessesTemplate() {
|
||||
$this->renderer->newsletter['body'] = json_decode(Fixtures::get('newsletter_body_template'), true);
|
||||
$template = $this->renderer->render();
|
||||
// !important should be stripped from everywhere except from
|
||||
// with the <style> tag
|
||||
expect(preg_match('/<style.*?important/s', $template['html']))
|
||||
->equals(1);
|
||||
expect(preg_match('/mailpoet_template.*?important/s', $template['html']))
|
||||
->equals(0);
|
||||
// !important should be stripped from everywhere except from with the <style> tag
|
||||
expect(preg_match('/<style.*?important/s', $template['html']))->equals(1);
|
||||
expect(preg_match('/mailpoet_template.*?important/s', $template['html']))->equals(0);
|
||||
|
||||
// spaces are only replaces in image tag URLs
|
||||
expect(preg_match('/image%20with%20space.jpg/s', $template['html']))->equals(1);
|
||||
expect(preg_match('/link%20with%20space.jpg/s', $template['html']))->equals(0);
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ Fixtures::add(
|
||||
"blocks": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "<a href=\"[link:newsletter_view_in_browser_url]\">View in browser link</a> <a data-post-id=\"10\" href=\"http://example.com\">Post link</a> Hello [subscriber:firstname | default:test] <a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe link</a> <a href=\"[link:subscription_manage_url]\">Manage subscription link</a>"
|
||||
"text": "<a href=\"[link:newsletter_view_in_browser_url]\">View in browser link</a> <a data-post-id=\"10\" href=\"http://example.com\">Post link</a> Hello [subscriber:firstname | default:test] <a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe link</a> <a href=\"[link:subscription_manage_url]\">Manage subscription link</a> <img src=\"http://example.com/image with space.jpg\"> <a href=\"http://example.com/link with space.jpg\">"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user