PrimeFaces 7.0 <p:textEditor HTML-sanitizer 丢弃文本格式,如居中。

问题描述 投票:1回答:1

在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 sanitizer就会删除我的格式化,所以文本最终没有格式化。

有一个方法可以解决这个问题,就是直接使用Quill,而不是Sanitize输入,这样做是可行的,但是我又面临其他问题,比如这个问题。

https:/github.comquilljsquillissues1379

也需要解决的问题。

请帮助我!我想知道,在PrimeFaces 8中,当使用HMTML -sanitizer时,似乎可以启用禁用HMTML -sanitizer。

primefaces jsf-2.2 quill html-sanitizing
1个回答
3
投票

在PrimeFaces 7的TextEditor中没有安全属性。如果你看一下TextEditorRenderer.decode的代码,你会发现sanitzier被称为

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 是可以在classpath上使用的。

htmlSanitizerAvailable = LangUtils.tryToLoadClassForName("org.owasp.html.PolicyFactory") != null

所以你要么:

  • 更新到PF 8
  • 确保你的classpath上没有这个类的名字。
  • 覆盖渲染器和改变检查的代码。
© www.soinside.com 2019 - 2024. All rights reserved.