开发者

How to prevent CKEditor from stripping < and > (greater-than/less-than)

开发者 https://www.devze.com 2023-01-13 21:28 出处:网络
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 tag.For example:

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 tag. For example: if I type <configuration deta开发者_开发知识库ils>, CKEditor will assume it is an HTML tag and put <configuration details></configuration details> in the html source, thus stripping it out altogether from the text. Argh!

Any ideas?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消