Replaces spaces in image URLs
This commit is contained in:
@@ -130,6 +130,10 @@ class Renderer {
|
|||||||
|
|
||||||
function postProcessTemplate($template) {
|
function postProcessTemplate($template) {
|
||||||
$DOM = $this->DOM_parser->parseStr($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');
|
$template = $DOM->query('.mailpoet_template');
|
||||||
// replace all !important tags except for in the body tag
|
// replace all !important tags except for in the body tag
|
||||||
$template->html(
|
$template->html(
|
||||||
|
@@ -444,11 +444,12 @@ class RendererTest extends \MailPoetTest {
|
|||||||
function testItPostProcessesTemplate() {
|
function testItPostProcessesTemplate() {
|
||||||
$this->renderer->newsletter['body'] = json_decode(Fixtures::get('newsletter_body_template'), true);
|
$this->renderer->newsletter['body'] = json_decode(Fixtures::get('newsletter_body_template'), true);
|
||||||
$template = $this->renderer->render();
|
$template = $this->renderer->render();
|
||||||
// !important should be stripped from everywhere except from
|
// !important should be stripped from everywhere except from with the <style> tag
|
||||||
// with the <style> tag
|
expect(preg_match('/<style.*?important/s', $template['html']))->equals(1);
|
||||||
expect(preg_match('/<style.*?important/s', $template['html']))
|
expect(preg_match('/mailpoet_template.*?important/s', $template['html']))->equals(0);
|
||||||
->equals(1);
|
|
||||||
expect(preg_match('/mailpoet_template.*?important/s', $template['html']))
|
// spaces are only replaces in image tag URLs
|
||||||
->equals(0);
|
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": [
|
"blocks": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"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