How do I stop CKEditor from stripping out code I don't want it to?

So this was an all-day troubleshooting “rabbit hole” to figure this out, but I think I’ve narrowed things down to CKEditor stripping out code I don’t want it to…

Here’s the basic gist of what happened today: Someone discovered that when viewing an email we sent out that in “dark mode” on an iPhone, one of the HTML colors (which happens to be one of our official branding colors, so it changing is bad) was shifting to a pinkish hue from a reddish hue. I investigated all sorts of things and ultimately determined that it’s only behaving this way when I send the message out with phpList. When I use the email system that our Admission division uses to send out the same (copy/paste of HTML source code from the original) message, it doesn’t color-shift.

Looking through the “Show Original” code for the phpList version of the message and the other version of the message (and converting those away from Quoted Printable so they’re user-readable), I have determined that the culprit is likely to be one line of code ("") that the phpList version doesn’t have but the other version does.

Figuring this would just be a matter of me editing the source code for the message within phpList, I went in and added the code and soon as I closed the Source view and opened it again, the added code was gone.

So, it is being stripped out by the CKEditor editor. I’ve tried all sorts of things to figure out how to make it not do that, but nothing has worked…it’s still stripping out that line of code when I put it in the editor.

My question is…how do I make the CKEditor in phpList not strip out that line of code (and, really, if the only way to do it is to have it not strip any lines of code out, that’s fine…I’m the only one that uses the phpList back-end here…)

Or, if I’m barking up the wrong tree and someone else has dealt with phpList-sent emails doing weird color-shifts in dark mode on iPhones or something and has figured out a way to resolve the issue, please let me know.

Thanks in advance for any help on this,

Doug Thompson
Manager of Web and Electronic Communications
Ohio Wesleyan University

Please use the code button </> when copying html so that it is shown literally.

Oops sorry about that (that’s what I get for making the post super-late in the work day):

<!DOCTYPE html>

(So basically, it’s stripping out the DOCTYPE declaration, causing the iPhone’s Apple Mail’s “dark mode” functionality to shift some of the colors incorrectly…at least that’s my theory)

@dethompsOWU How are you composing the campaign? The default settings for ckeditor are to allow full page editing of a template but not of a campaign content. That means the doctype would be removed if you try to add it to a campaign.

If you are always editing the complete email (so would not be using templates) then you can change this behaviour on the Settings page
image

Or, if you are composing the email outside of phplist and then copying/pasting the complete html, you could disable ckeditor entirely as it might not be adding anything for you.

You know, I saw that setting yesterday but for some reason skipped over it…

However, changing that setting to “Yes” (and even doing a browser cache clear and browser restart just in case) doesn’t appear to have done anything…when I paste in the

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

code, and then click the “Source” button to be taken back to the WYSIWYG editor, then click the “Source” button again, the added code is gone

@dethompsOWU You need to change “templates” to No and “campaigns” to Yes. It is not allowed for both be Yes and templates takes precedence.

@duncanc Ah good to know. Did that and the problem initially seemed to be resolved (at least, toggling the “Source” button didn’t make the added code go away), but a test-send of the campaign to myself resulted in a blank-content email. I tried a bunch of permutations of various HTML code, but the sent message was blank each time. Only when I reverted the settings for “templates” and “campaigns” did the content send again (but, of course, the “color shift” thing mentioned upthread continues to be an issue…)

@dethompsOWU Just to be clear as what you are doing.

On the Content tab you have entered the complete email, and on the Format tab a template has not been selected.

Does the “blank” email have any non-displayed content when you view the source, and is the plain-text part also empty?

@duncanc Yup it’s exactly as you describe…the complete email is on the Content tab and there aren’t any template options on the Format tab (because I have no templates defined in the system)

I should say that the email wasn’t fully blank…it did have the “Subject”, “From”, and “Footer” text from the Content tab (so only the “Compose Message” part is what was actually blank.

Looking at the “Show Original” source code for the message in Gmail, it appears that the text content of the message (in the text/plain section) is there…it’s only the HTML content (in the text/html section) that’s not:thinking:

@duncanc And this whole “WYSIWYG is stripping out tags” thing may not be the culprit in the dark-mode color-shift thing I mentioned in my original post in the thread…it’s just my best guess as to what might be happening, based upon spending nearly the entire day yesterday troubleshooting…

@dethompsOWU Can you give me access to take a look. If so, create a new super admin and give me the details in a private message - click on my name/photo to do that. You can revoke the new admin at any time.

@duncanc Two problems:

  1. If I click on your name or photo, I’m not finding any way to send you a private message…just a link to your web page and info about your Discuss badges and whatnot…
  2. I can’t figure out a way to add an administrator to phpList without having an email address for that user…so what should I use for you?

@dethompsOWU Thanks for the admin id.

I think what was happening when you changed full-page for templates to be no and for campaigns to be yes was that ckeditor added the outline html (html, head, body elements) before your existing html instead of wrapping that. That is why you saw an empty email.

Possibly ckeditor didn’t recognise the first element, meta as being valid content for when full-page is no. My recollection is that it does usually wrap content with a body element when full-page is changed from no to yes.

I have manually edited the html of the campaign in draft status, id 303, and now the structure looks correct and is kept when moving away and then moving back.

When you create a new campaign the outline html should be provided automatically.

Makes sense (and seems like something I wouldn’t have noticed). At any rate, I can confirm that it’s no longer stripping code when I toggle between the Source and the WYSIWYG :slight_smile: Thanks for that!

But, that only affected some of the “dark mode color shift” thing…namely the header and the line in the footer and the background color. The headline text is still shifting to pink for some reason. But at least the header/footer/background are consistent between Android and iPhone “dark mode” now, right? :slight_smile:

I’m going to talk to the person who this email is for about maybe doing away with the red color (and, thus, the pink shift) for the text elements and we’ll see where things go from there.

I’m just glad that we’re using phpList for only (for the most part) this one type of message…

Thanks so much for your help! I’ll remove that SuperAdmin account after I send this reply.