浏览代码

fix: limit allowed attributes for lazy images (#17775)

Co-Authored-by: Sagar Vora <sagar@resilient.tech>
(cherry picked from commit ce164d59e3)

Co-authored-by: Ankush Menat <ankush@frappe.io>
version-14
mergify[bot] 2 年前
committed by GitHub
父节点
当前提交
1311564825
找不到此签名对应的密钥 GPG 密钥 ID: 4AEE18F83AFDEB23
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. +3
    -0
      frappe/website/js/website.js

+ 3
- 0
frappe/website/js/website.js 查看文件

@@ -377,10 +377,13 @@ $.extend(frappe, {
// To use this feature, instead of adding an img tag, add
// <div class="website-image-lazy" data-class="img-class" data-src="image.jpg" data-alt="image"></div>

const allowed_attributes = ["src", "srcset", "alt", "title", "width", "height"];

function replace_with_image(target) {
const $target = $(target);
const attrs = $target.data();
const data_string = Object.keys(attrs)
.filter((key) => allowed_attributes.includes(key))
.map((key) => `${key}="${attrs[key]}"`)
.join(" ");
$target.replaceWith(`<img ${data_string}>`);


正在加载...
取消
保存