fix(web): escape Lucene quotes in searchReleaseGroup query

A `"` or `\` inside artist/album terminates the quoted Lucene phrase
and corrupts the MusicBrainz search query. Escape both terms before
interpolation.
This commit is contained in:
Jonathan
2026-07-13 00:37:00 +02:00
parent fd0bb6aaa0
commit 9c793f42d1
2 changed files with 14 additions and 1 deletions
+5 -1
View File
@@ -54,8 +54,12 @@ export async function browseReleaseGroups(artistMbid: string): Promise<ReleaseGr
return out;
}
function escapeLucenePhrase(s: string): string {
return s.replace(/[\\"]/g, (c) => "\\" + c);
}
export async function searchReleaseGroup(artist: string, album: string): Promise<ReleaseGroupMatch | null> {
const query = `releasegroup:"${album}" AND artist:"${artist}"`;
const query = `releasegroup:"${escapeLucenePhrase(album)}" AND artist:"${escapeLucenePhrase(artist)}"`;
const data = await mbGet(`/release-group?query=${encodeURIComponent(query)}&fmt=json&limit=5`);
const groups: any[] = data["release-groups"] ?? [];
if (groups.length === 0) return null;