BUG - HTML Template editor removes html - SuiteCRM 7.9.0

I tried creating a new email template with the HTML Template Editor.

The code was:

<html>
<head>
<style>
h1 {
  color: red;
}
p {
  color: green;
}
a{
  color: yellow;
}
</style>
</head>
<body>
<h1>Email Title</h1>
<p>Normal paragraph text</p>
<a href="">link text</a>
</body>
</html>

but upon saving it was saved as:

<h1>Email Title</h1>
<p>Normal paragraph text</p>
<a href="">link text</a>

with all styling removed!

So I tried again removing the html, head and body tags in the following way:

<style>
h1 {
  color: red;
}
p {
  color: green;
}
a{
  color: yellow;
}
</style>
<h1>Email Title</h1>
<p>Normal paragraph text</p>
<a href="">link text</a>

and the result was still:

<h1>Email Title</h1>
<p>Normal paragraph text</p>
<a href="">link text</a>

again with all styling removed!

Considering my other post in which I highlight the incompatibility between the three editors, here are some considerations:

  1. It would be useful to identify one only editor that allows to insert predefined blocks as well as edit any part of the HTML without any filtering of the html.
  2. TinyMCE used to allow the editing of HTML but this was filtered Now it is no longer possible
  3. Instead of allowing TinyMCE to modify (and filter) the HTML now there is a third editor which promises editing of HTML but does nothing but what the older html editing done from TinyMCE was doing.

My immediate suggestions:

  1. Allow html editing in TinyMCE in the same way it used to be and remove the new HTML editor since it adds nothing to the previous situation
  2. Alternatively to removing the HTML editor (but still allowing TinyMCE to modify html as in the past), remove all filtering from the new HTML Editor

For future releases (although in anorganisation with many users that use and modify templates this is not acceptable)
. Once the HTML has been bodified do not allow editing of a specific template with Mozaik or TinyMCE anymore because filters that are applied will break the most recent version.

The ideal situation would be an editor that already manages such situations (for example in MailChimp if you modify the HTML directly, no filters are no longer applied and the “power editor” equivalent to Mozaik gets deactivated at the template level (or something similar).

When it is saved, it is ran through the HTML purifier which strips out certain data. http://htmlpurifier.org/

@Simeon: I know that the purifier is applied. This was exactly my comment

But what’s the point of having the option of editing HTML if then the code is modified.

It was better when the same was achieved directly from within TinyMCE.

The ideal would be (in my personal order of preference)

  1. An editor that allows maximum flexibility (i.e. wysiwig, insert predefined blocks, edit html with purification, edit html without any filtering)

Since this is not possible at the moment a very easy setup would be a slight modification of the current set-up:

  1. Three editors as it is now:
    Mozaik for inserting blocks
    • TinyMCE with the possibility to edit html and purify the result (same as it used to be)
    • TinyMCE with the possibility to edit html without any filtering applied - better TinyMCE with no purifying than just a textarea!
      (the implementation of this solution is simple and would make nearly everyone happy!)

Furthermore:

The choice of the editor should be at the template level and not at the user level. (If you look at my other post on the issue you will understand that doing it at the user level does not work: https://suitecrm.com/forum/feedback/14484-bug-email-template-editor-suitecrm-7-9-0). Or, even better give both options with precedence given at the choice made at the template level. (there could be an extra level of sophistication which would allow moving forward but not backward in the following levels of priority:

Mozaik -> TinyMCE -> HTML
(from my experience this is how MailChimp or other Mass emailing services work: You can start with the blocks editor but if you modify certain parts of the HTML (not for just any modification) then you have to stick to modifying HTML only - or something similar)

Since 7.9.0 is the version in which this supposed enhancement is being made, this is the version in which immediate action has to be taken otherwise we will have to wait for another year with a not-working nor practical solution so I hope that you can spend some time and implement at least the secon option I listed above, which is just a small amount of work.

Additionally some extra work is needed with respect to where the template has to be chosen. The way it is done in 7.9.0 is not just a different functionality, it is a clear bug.

Yes, I agree with you…why to have a Direct HTML editor if code is filtered??

I use html 5 to write nice email…but most of times suitecrm messes up.

I always waste a lot of time…any workaround instead of writing directly mysql table?

thank you?

@stfnet

If you agree plese go to github and put a like on the issue and my comments.
https://github.com/salesagility/SuiteCRM/issues/3672

Unfortunately I do not have a workaround at the moment. I will have some time to look at it in two weeks.

Work around is as follows:

in file /data/SugarBean.php
comment out line 1938 and 1944

//$this->$key = SugarCleaner::cleanHtml($this->$key, true);
//$this->$key = SugarCleaner::cleanHtml($this->$key);

Please note : This disables cleaning Html all together. So be very careful about any html you enter anywhere. Use at your own risk.
This change is not upgrade safe.

1 Like

I have even tried to copy HTML code directly into the database field:

email_templates.bodyhtml

without ever opening it up in the backend - just reference in choose template

my email might look like this: (a snippet)


<td style="font-family:Segoe UI, News Gothic MT,Helvetica,Arial,sans-serif; font-size: 15px; line-height: 24px; margin: 0; background-color: #fff; color: #2d4050; ">
<p>
Hi $contact_first_name,
</p>				
<p>
Join us for another networking session on the terrace.
<br />
Come along and catch up with what&rsquo;s happening in our industry
<br />
Drinks and nibblies with a great mix of industry people.
</p>
</td>

then I send the email and it is not as formatted

I then copy the code again from the field in database and it has changed (at what stage??? During send???)

to this:


<td style="font-family:'Segoe UI', 'News Gothic MT', Helvetica, Arial, sans-serif;font-size:15px;line-height:24px;margin:0px;background-color:#ffffff;color:#2d4050;padding:3px 3px 3px 0px;"><p style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:22.4px;color:#444444;padding:0px;margin:0px;">Hi $contact_first_name,</p><p style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:22.4px;color:#444444;padding:0px;margin:0px;">Join us for another networking session on the terrace. <br style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:22.4px;color:#444444;padding:0px;margin:0px;" />Come along and catch up with what&rsquo;s happening in our industry <br style="font-family:Arial, Helvetica, sans-serif;font-size:14px;line-height:22.4px;color:#444444;padding:0px;margin:0px;" />Drinks and nibblies with a great mix of industry people.</p></td>

it adds
tags in some places with overriding style

it changes all my styles etc…

How can I disable this

@jacograaff there have been several fixes in these matters, which SuiteCRM version are you running?