Merge pull request #183 from Sijisu/main
Fix numerous XSS vulnerabilities when rendering 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 { sanitize } from './includes/sanitize'
|
||||
|
||||
function escapeHtml (str: string): string {
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
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, ''') : ''
|
||||
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 = [
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><%- title %></title>
|
||||
<title><%= title %></title>
|
||||
<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
|
||||
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 name="twitter:title" content="<%- title %>">
|
||||
<meta name="twitter:title" content="<%= title %>">
|
||||
<meta name="twitter:image" content="<%- publicBaseUrl %><%- items[0].previewUrl %>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<% } %>
|
||||
@@ -20,7 +20,7 @@
|
||||
<body>
|
||||
<div id="header">
|
||||
<% if (showTitle) { %>
|
||||
<h1><%- title || 'Gallery' %></h1>
|
||||
<h1><%= title || 'Gallery' %></h1>
|
||||
<% } %>
|
||||
<%
|
||||
if (showDownload) {
|
||||
|
||||
Reference in New Issue
Block a user