如何防止CKEditor剥离<和>(大于/小于)

发布于 2024-09-16 01:43:43 字数 310 浏览 2 评论 0原文

每次我在 CKEditor 窗口中输入 <> 并保存,然后返回时,CKEditor 都会将它们替换为括号内键入的内容以及随附的内容结束标签。例如: 如果我输入 ,CKEditor 会假设它是一个 HTML 标签,并将 放入 html 源中,因此将其从文本中完全删除。啊!

有什么想法吗?

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 details>, 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪操控生活 2024-09-23 01:43:43

是的,这真的很痛苦。

到目前为止我发现的唯一解决方法是使用

CKEDITOR.instances.myInst.setData(myData);

This 实际上正确处理转义与未转义的 html,所以你的 <和>将正确显示为小于和大于符号,而不是被解释为标记。

我还没有找到一种方法来让它与内联数据一起使用。 setData() 解决方法非常笨拙。

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.

鸠魁 2024-09-23 01:43:43

我想出的最好的办法是使用一个隐约小于符号的unicode字符,或者一些功能上让人联想到的东西,例如,左箭头可以指示重定向。

您需要有一个草稿页/记事本之类的东西来打开您的角色,这样您就可以在处理救生文档时进行剪切和粘贴(或查找/替换)。

以下是我需要填写的一些符号:

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

这些符号中的任何一个可能会也可能不会工作,具体取决于浏览器、操作系统和/或应用程序 unicode 支持和(错误)配置。

复制并通过 google 搜索查找任意字符的 unicode/html/long-description(例如'MODIFIER LETTER RIGHT ARROWHEAD' (U+02C3)),并使用该信息查找相关或匹配的符号。

这里有几个例子。您需要合适的浏览器和 3D 眼镜才能充分欣赏它们。

  • 这看起来没问题!

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

  • 没那么多,但它是一个很好的对话开头:

◄配置详细信息►◄/配置详细信息►

  • 甚至可能

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

但是哇,这太可怕了。它仍然比拥有小于号和被剥离后的所有内容要好。

可能有更好的符号,甚至是一些修复图像的技巧。但这是我的快速解决办法。
无论如何,该解决方案的适用性将取决于各种因素,包括对字符集不精确的容忍度以及前面提到的操作系统、软件、浏览器对奇怪的 unicode 字符的支持。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文