From c07ef0fab3b0cebf4c97c83a6dbe13503f812dfc Mon Sep 17 00:00:00 2001 From: Alan Grainger <16197738+alangrainger@users.noreply.github.com> Date: Sat, 30 May 2026 10:55:50 +0800 Subject: [PATCH] Ensure ipp.lightbox.options is an object --- app/public/web.js | 4 ++-- app/src/render.ts | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/public/web.js b/app/public/web.js index 3c4985f..6f85ad8 100644 --- a/app/public/web.js +++ b/app/public/web.js @@ -37,7 +37,7 @@ import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js' * @property {boolean} [showArrows] * @property {boolean} [showDownload] * @property {boolean} [mobileArrows] - * @property {Record} [options] + * @property {Record} [options] */ /** @@ -668,7 +668,7 @@ function buildDataSource () { } function initLightbox () { - const { options = {} } = lightboxConfig; + const { options = {} } = lightboxConfig lightbox = new PhotoSwipeLightbox({ bgOpacity: 1, diff --git a/app/src/render.ts b/app/src/render.ts index a7b7e61..437c63d 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -284,6 +284,12 @@ class Render { // item if the cover asset has been filtered out (e.g. trashed). const coverId = share.album?.albumThumbnailAssetId const ogImageItem = (coverId && items.find(i => i.id === coverId)) || items[0] + // Guard against an operator setting ipp.lightbox.options to a non-object; + // a string would otherwise spread character-by-character into PhotoSwipe. + const rawLightboxOptions = getConfigOption('ipp.lightbox.options', {}) + const lightboxOptions: Record = (rawLightboxOptions && typeof rawLightboxOptions === 'object' && !Array.isArray(rawLightboxOptions)) + ? rawLightboxOptions as Record + : {} const props: GalleryProps = { items, title: this.title(share), @@ -299,7 +305,7 @@ class Render { showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true), showArrows: !!getConfigOption('ipp.lightbox.showArrows', true), mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false), - options: getConfigOption('ipp.lightbox.options', {}) as Record + options: lightboxOptions }, groupByDate }