Escape attributes in lightbox image

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2020-12-21 14:10:03 +08:00
parent 381b3ff78e
commit 26a2c746d3
No known key found for this signature in database
GPG Key ID: A76CBD50B22052C0
1 changed files with 2 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import './lightbox.css'
import escape from 'lodash/escape'
let images = []
/** @type {HTMLImageElement} */
@ -74,7 +75,7 @@ function setImageInner (img, lightBoxContainer) {
const src = img.getAttribute('src')
const alt = img.getAttribute('alt')
lightBoxContainer.querySelector('.lightbox-inner').innerHTML = `<img src="${src}" alt="${alt}" draggable="false">`
lightBoxContainer.querySelector('.lightbox-inner').innerHTML = `<img src="${escape(src)}" alt="${escape(alt)}" draggable="false">`
addImageDragListener(lightBoxContainer.querySelector('.lightbox-inner img'))
}