Parcourir la source

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] il y a 2 ans
committed by GitHub
Parent
révision
1311564825
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. +3
    -0
      frappe/website/js/website.js

+ 3
- 0
frappe/website/js/website.js Voir le fichier

@@ -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}>`);


Chargement…
Annuler
Enregistrer