From 122a4ec1037dfd027d9f3f7d5d25ce63dfe4450a Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 26 Jun 2026 02:01:08 +0200 Subject: fix: decode wiki article names for clean storage - wikidata.go: url.PathUnescape SPARQL titles before storing - wikiarticle.go: PathUnescape on read, PathEscape on send - DB holds decoded names; URLs are always freshly encoded --- src/wikiarticle.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/wikiarticle.go') diff --git a/src/wikiarticle.go b/src/wikiarticle.go index 864f6c4..9c5845f 100644 --- a/src/wikiarticle.go +++ b/src/wikiarticle.go @@ -59,6 +59,10 @@ func (a *App) fetchWikiArticlesData() error { if err := rows.Scan(&r.id, &r.imdbID, &r.wikiArticle); err != nil { return fmt.Errorf("scan row: %w", err) } + // Decode — wiki_article may be URL-encoded from SPARQL + if dec, err := url.PathUnescape(r.wikiArticle); err == nil { + r.wikiArticle = dec + } entries = append(entries, r) } if err := rows.Err(); err != nil { @@ -155,11 +159,10 @@ func (a *App) fetchWikiArticlesData() error { return nil } -// queryWikiArticle fetches and parses a single wiki article from the custom server. func (a *App) queryWikiArticle(name string) (wikiArticleEntry, int, error) { - // Build URL manually — name is already URL-encoded in the DB + // Build URL — name is decoded from DB, encode it for the request reqURL := fmt.Sprintf("%s?username=%s&name=%s", - a.Config.WikiServer, url.QueryEscape(a.Config.WikiUsername), name) + a.Config.WikiServer, url.QueryEscape(a.Config.WikiUsername), url.PathEscape(name)) var resp *http.Response var err error -- cgit v1.2.3