diff --git a/src/backend/model/database/CoverManager.ts b/src/backend/model/database/CoverManager.ts index 5d027f09..444417cd 100644 --- a/src/backend/model/database/CoverManager.ts +++ b/src/backend/model/database/CoverManager.ts @@ -161,7 +161,9 @@ export class CoverManager implements IObjectManager { }); } else { q.orWhere('directory.path GLOB :path', { - path: DiskMangerWorker.pathFromParent(dir) + '*', + path: DiskMangerWorker.pathFromParent(dir) + // glob escaping. see https://github.com/bpatrik/pigallery2/issues/621 + .replaceAll('[', '[[]') + '*', }); } }) diff --git a/test/backend/unit/model/sql/PreviewManager.spec.ts b/test/backend/unit/model/sql/CoverManager.spec.ts similarity index 97% rename from test/backend/unit/model/sql/PreviewManager.spec.ts rename to test/backend/unit/model/sql/CoverManager.spec.ts index 1ed3be43..f6e5c2ac 100644 --- a/test/backend/unit/model/sql/PreviewManager.spec.ts +++ b/test/backend/unit/model/sql/CoverManager.spec.ts @@ -84,7 +84,7 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => { const setUpTestGallery = async (): Promise => { - const directory: ParentDirectoryDTO = TestHelper.getDirectoryEntry(); + const directory: ParentDirectoryDTO = TestHelper.getDirectoryEntry(null, 'éűáúőóüöÉŰÚŐÓÜÖ[]^[[]]][asd]'); subDir = TestHelper.getDirectoryEntry(directory, 'The Phantom Menace'); subDir2 = TestHelper.getDirectoryEntry(directory, 'Return of the Jedi'); p = TestHelper.getPhotoEntry1(subDir); @@ -178,7 +178,7 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => { const conn = await SQLConnection.getConnection(); await conn.createQueryBuilder() - .update(DirectoryEntity).set({validCover: false}).execute(); + .update(DirectoryEntity).set({validCover: false}).execute(); expect(await pm.getPartialDirsWithoutCovers()).to.deep.equalInAnyOrder([dir, subDir, subDir2].map(d => partialDir(d))); }); @@ -279,13 +279,13 @@ describe('CoverManager', (sqlHelper: DBTestHelper) => { expect(subdir.cover.id).to.equal(p2.id); await conn.createQueryBuilder() - .update(DirectoryEntity) - .set({validCover: false, cover: null}).execute(); + .update(DirectoryEntity) + .set({validCover: false, cover: null}).execute(); expect((await selectDir()).cover).to.equal(null); const res = await gm.getParentDirFromId(conn, - (await gm.getDirIdAndTime(conn, dir.name, dir.path)).id); + (await gm.getDirIdAndTime(conn, dir.name, dir.path)).id); subdir = await selectDir(); expect(subdir.validCover).to.equal(true); expect(subdir.cover.id).to.equal(p2.id);