divan/GanjooRazor
Ehsan Mohandesi cb7b1b03a3 Replace Spotify search with a validated music link box
The Spotify Web API integration stopped working, leaving /spotify unable to
suggest songs at all. Replace the artist/album/track search flow with a single
box where the user pastes a link to the track on a music service.

Links are checked against a hardcoded allow-list of legal streaming and store
domains so links to ripped audio cannot be submitted. The check lives in the
service layer, not just the page: any authenticated user can POST to
/api/ganjoor/song directly and bypass the UI. Hosts are matched against the
full host or a dot-prefixed suffix, so look-alikes such as
open.spotify.com.evil.com are rejected; https is required, and userinfo and
non-default ports are refused. Accepted URLs are canonicalised - https,
lowercased host, tracking parameters stripped - so the same track always yields
the same stored URL and duplicate detection actually works.

Links are stored under one new type, PoemMusicTrackType.MusicUrl, with the
platform derived from the host at render time. That needs no migration or
backfill, and supporting another service later needs no new enum value. The
duplicate check no longer keys on TrackType, which closes a gap where the same
URL could be resubmitted as a different type. Several links per poem remain
allowed; only an identical URL for the same poem is refused.

The Spotify search page and its OAuth plumbing are kept and simply redirect to
/musiclink while the existing SpotifyWorking flag is false, so the old flow can
be restored if that API ever works again.

Track URLs are no longer written through Html.Raw into href attributes. They
previously came from the Spotify API; now that they are user supplied, encoding
them prevents stored XSS.

Also fixes two latent bugs in SuggestSong that this flow would have hit: a null
dereference when TrackUrl is empty, and a singer lookup that matched any singer
with an empty Url.
2026-09-13 22:16:18 -05:00
..
.config docs: #292 db migration and some other changes and fixes 2022-03-09 20:19:44 +03:30
Areas Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00
Models warning fix 2026-07-19 16:50:15 +03:30
Pages Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00
Properties .net 10 publish profiles 2026-07-10 15:56:40 +03:30
Utils caching fixes 2026-09-13 14:56:55 +03:30
wwwroot Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00
APIRoot.cs semantic search 2026-09-10 13:03:20 +03:30
appsettings.Development.json moving caching poets to service level 2021-05-16 10:15:28 +04:30
appsettings.json caching improvements 2026-09-12 15:05:43 +03:30
GanjooRazor.csproj upgrading to .net 10 2026-07-05 21:14:32 +03:30
Program.cs #112 copying GanjoorService settings to GanjooRazor 2021-05-09 19:34:22 +04:30
Startup.cs Replace Spotify search with a validated music link box 2026-09-13 22:16:18 -05:00