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
+9
View File
@@ -47,4 +47,13 @@ describe("musicbrainz module", () => {
vi.stubGlobal("fetch", vi.fn(() => jsonResponse({ "release-groups": [] })));
expect(await searchReleaseGroup("Nobody", "Nothing")).toBeNull();
});
it("escapes quotes in the release-group query", async () => {
const fetchMock = vi.fn((_url: string, _init?: RequestInit) => jsonResponse({ "release-groups": [] }));
vi.stubGlobal("fetch", fetchMock);
await searchReleaseGroup("AC/DC", 'Back in "Black"');
const [url] = fetchMock.mock.calls[0];
// the decoded query must contain the escaped quote, not a bare one that closes the phrase
expect(decodeURIComponent(url)).toContain('Back in \\"Black\\"');
});
});