在 PrimeFaces 8 中,似乎可以在使用时启用/禁用 HMTML -sanitizer<p:textEditor
只需指定组件secure='false'
用于禁用它和secure='true'
用于启用它。我尝试在 PrimeFaces 7.0 中禁用它,如下所示:
<p:textEditor id="quillToolbarId" secure='false' widgetVar="editor2" height="300" value="#{editTemplatesBean.kaufAnbotTemplate}" placeholder="Enter your content">
但消毒剂似乎仍然有效。
我的问题是,每当我将 primeFaces p:textEditor 中的文本格式化为居中对齐时,HTML 清理程序只会删除我的格式,因此文本最终不会格式化。
解决这个问题的一种方法是直接使用 Quill,而不是清理输入。这可行,但随后我面临其他问题,例如:
https://github.com/quilljs/quill/issues/1379 https://github.com/quilljs/quill/issues/1379
这也需要解决。
请帮忙!
PrimeFaces 7 的 TextEditor 中没有安全属性。如果您查看 TextEditorRenderer.decode 的代码,您将看到调用了 sanittier
if (PrimeApplicationContext.getCurrentInstance(context).getEnvironment().isHtmlSanitizerAvailable()) {
value = HtmlSanitizer.sanitizeHtml(value,
editor.isAllowBlocks(), editor.isAllowFormatting(),
editor.isAllowLinks(), editor.isAllowStyles(), editor.isAllowImages());
}
如果您查看 PrimeEnvironment,您会发现如果类org.owasp.html.PolicyFactory
在类路径上可用:
htmlSanitizerAvailable = LangUtils.tryToLoadClassForName("org.owasp.html.PolicyFactory") != null
所以你要么:
- 更新至 PF 8
- 确保类路径上没有此类
- 覆盖渲染器并更改/删除检查代码
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)