Properly escape text coming from the Immich instance

This commit is contained in:
Sijisu
2026-02-08 22:59:58 +01:00
parent 30a00a769d
commit eaaeacb4c6
2 changed files with 14 additions and 5 deletions
+10 -1
View File
@@ -6,6 +6,15 @@ import archiver from 'archiver'
import { respondToInvalidRequest } from './invalidRequestHandler'
import { sanitize } from './includes/sanitize'
function escapeHtml (str: string): string {
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}
class Render {
lgConfig
@@ -134,7 +143,7 @@ class Render {
const thumbnailUrl = immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset))
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, '&apos;') : ''
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? escapeHtml(asset.exifInfo.description) : ''
// Create the full HTML element source to pass to the gallery view
const itemHtml = [