Skip to content Skip to sidebar Skip to footer

How To Prevent CKEditor From Stripping < And > (greater-than/less-than)

Every time I enter < or > in a CKEditor window, save, and then come back to it, CKEditor replaces them with whatever was typed within the brackets and the accompanying end ta

Solution 1:

Yeah, this is a real pain.

The only workaround I've found so far is to use

CKEDITOR.instances.myInst.setData(myData);

This actually handles escaped vs. unescaped html correctly, so your < and > will come out correctly, as less-than and greater-than signs, instead of being interpreted as markup.

I haven't found a way to get this to work with inlined data yet. The setData() workaround is pretty clunky.


Solution 2:

The best I've come up with is to use a unicode character which is vaguely less-than-sign-ish, or something functionally reminiscent, for instance, a left arrow could indicate redirection.

You'll need to have a scratch page / notepad kind of thing with your characters open, so you can cut and paste (or Find/Replace) as you're working on your life-saving docs.

Here are a few symbols I've gotten to fill in:

⨞ ◀ ◄ ⇦ ⍃ ❮ ⍄ ► ▶ ▷ ❭ ˃

Any of these may or may not work depending on browser, OS and/or application unicode support and (mis)configuration.

Copy and google-search to find unicode/html/long-description (e.g.,'MODIFIER LETTER RIGHT ARROWHEAD' (U+02C3)) for any character, and use that info to find related or matching symbols.

Here are a couple of examples. You'll need a proper browser and 3D glasses to appreciate them fully.

  • This looks all right!

mysql -u root -p xxxxxx ❮​ /usr/share/icinga2/schema.sql

  • Not so much, but it's a good conversation starter:

◄configuration details►◄/configuration details►

  • Maybe even

mysql -u root -p passw*t ◄ nerf_ischemia.sql

But wow, that's hideous. It's still better than having the less-than sign and everything after it being stripped.

There may be a better symbol out there, or even some hack with infixing an image. But that's my quick fix. In any case, the applicability of this solution is going to depend on various factors including tolerance for character-set imprecision as well as the previously-mentioned OS, software, browser weird-unicode-character support.


Post a Comment for "How To Prevent CKEditor From Stripping < And > (greater-than/less-than)"