From c9d23f25e10ed054690a8e8eb83f8e742a7533f2 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 26 Jun 2026 01:53:01 +0200 Subject: fix: avoid double URL-encoding of wiki article names - wiki_article values are already URL-encoded in the DB - Build query URL manually instead of url.Values.Encode() - Only escape username (not pre-encoded) --- src/wikiarticle.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/wikiarticle.go b/src/wikiarticle.go index 984eac3..864f6c4 100644 --- a/src/wikiarticle.go +++ b/src/wikiarticle.go @@ -28,6 +28,7 @@ type wikiArticleEntry struct { // fetchWikiArticlesData queries the custom wiki server for all entries // that have a wiki_article and updates the imdb table with extracted fields. func (a *App) fetchWikiArticlesData() error { + /* rows, err := a.DB.Query(` SELECT id, imdb_id, wiki_article FROM imdb WHERE wiki_article IS NOT NULL @@ -35,6 +36,13 @@ func (a *App) fetchWikiArticlesData() error { AND (synopsis IS NULL OR description IS NULL OR year IS NULL OR poster_url IS NULL OR license IS NULL OR license_url IS NULL OR num_accolades IS NULL) `) + */ + rows, err := a.DB.Query(` + SELECT id, imdb_id, wiki_article FROM imdb + WHERE wiki_article IS NOT NULL + AND (synopsis IS NULL OR description IS NULL OR year IS NULL + OR poster_url IS NULL OR license IS NULL OR license_url IS NULL OR num_accolades IS NULL) + `) if err != nil { return fmt.Errorf("query wiki articles: %w", err) } @@ -149,10 +157,9 @@ func (a *App) fetchWikiArticlesData() error { // queryWikiArticle fetches and parses a single wiki article from the custom server. func (a *App) queryWikiArticle(name string) (wikiArticleEntry, int, error) { - reqURL := a.Config.WikiServer + "?" + url.Values{ - "username": {a.Config.WikiUsername}, - "name": {name}, - }.Encode() + // Build URL manually — name is already URL-encoded in the DB + reqURL := fmt.Sprintf("%s?username=%s&name=%s", + a.Config.WikiServer, url.QueryEscape(a.Config.WikiUsername), name) var resp *http.Response var err error -- cgit v1.2.3