Skip to content

Commit aa93d20

Browse files
committed
chore(listenbrainz): blacklist non-coverartarchive urls for cover endpoint
1 parent 3905ce1 commit aa93d20

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pages/api/listenbrainz/cover.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export const GET: APIRoute = async ({ url }) => {
3232
const imageUrl = url.searchParams.get('url');
3333
const wantBlurhash = url.searchParams.get('blurhash') === 'true';
3434

35-
if (!imageUrl || !/^https?:\/\//.test(imageUrl)) {
35+
// Only allow Cover Art Archive URLs
36+
const coverArtArchivePattern = /^https?:\/\/(?:[^.]+\.)?coverartarchive\.org\//i;
37+
if (!imageUrl || !coverArtArchivePattern.test(imageUrl)) {
3638
return new Response('Missing or invalid url parameter', { status: 400 });
3739
}
3840

0 commit comments

Comments
 (0)