Properly escape text coming from the Immich instance
This commit is contained in:
+10
-1
@@ -6,6 +6,15 @@ import archiver from 'archiver'
|
|||||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||||
import { sanitize } from './includes/sanitize'
|
import { sanitize } from './includes/sanitize'
|
||||||
|
|
||||||
|
function escapeHtml (str: string): string {
|
||||||
|
return str
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''')
|
||||||
|
}
|
||||||
|
|
||||||
class Render {
|
class Render {
|
||||||
lgConfig
|
lgConfig
|
||||||
|
|
||||||
@@ -134,7 +143,7 @@ class Render {
|
|||||||
|
|
||||||
const thumbnailUrl = immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
|
const thumbnailUrl = immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
|
||||||
const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset))
|
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, ''') : ''
|
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
|
// Create the full HTML element source to pass to the gallery view
|
||||||
const itemHtml = [
|
const itemHtml = [
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title><%- title %></title>
|
<title><%= title %></title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||||
<%
|
<%
|
||||||
// Add an og-image using the first image's thumbnail
|
// Add an og-image using the first image's thumbnail
|
||||||
if (items?.[0]?.previewUrl) {
|
if (items?.[0]?.previewUrl) {
|
||||||
%>
|
%>
|
||||||
<meta property="og:title" content="<%- title %>">
|
<meta property="og:title" content="<%= title %>">
|
||||||
<meta property="og:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
<meta property="og:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
||||||
<meta name="twitter:title" content="<%- title %>">
|
<meta name="twitter:title" content="<%= title %>">
|
||||||
<meta name="twitter:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
<meta name="twitter:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<% if (showTitle) { %>
|
<% if (showTitle) { %>
|
||||||
<h1><%- title || 'Gallery' %></h1>
|
<h1><%= title || 'Gallery' %></h1>
|
||||||
<% } %>
|
<% } %>
|
||||||
<%
|
<%
|
||||||
if (showDownload) {
|
if (showDownload) {
|
||||||
|
|||||||
Reference in New Issue
Block a user