跳转至

pl-xss-safe元件

从 HTML 中删除潜在危险的脚本。在解析和显示学生提供的内容时建议这样做。该元素将删除一些可能由学生恶意插入的元素,例如脚本和触发器。请注意,此元素解析的任何代码都必须由浏览器直接支持,即它不能包含 ZJUI-Learn 元素或特殊标记。

样品元素

question.html
<!-- Content coming from a submitted file (e.g., pl-file-editor, pl-file-upload) -->
<pl-xss-safe submitted-file-name="answer.html"></pl-xss-safe>

<!-- Content coming from a regular element (e.g., pl-string-input) -->
<pl-xss-safe contents="{{submitted_answers.answer}}"></pl-xss-safe>

定制

属性 类型 默认 描述
contents 字符串 要显示的原始内容。
language 字符串 html 所提供代码的语言。当前支持值“html”或“markdown”。
source-file-name 字符串 具有要使用的现有代码的源文件的名称(而不是使用元素标记之间的现有代码,如上面的代码片段所示)。
submitted-file-name 字符串 用户提交的文件的名称(通常使用 pl-file-editorpl-file-upload 元素)以及要使用的代码。

注意,在同一元素中只能提供属性source-file-namesubmitted-file-namecontents之一。

示例实现

  • [演示/markdownEditorLivePreview]
  • [元素/xssSafe]

参见