fix(feeds): handle unicode escaped url characters (#1942)

* fix(rss): handle unicode escaped url characters

* refactor: simplify URL encoding function name

Co-authored-by: nuxen <47067662+nuxencs@users.noreply.github.com>

* feat(feeds): sanitize download url

---------

Co-authored-by: nuxen <47067662+nuxencs@users.noreply.github.com>
Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
soup 2025-01-18 22:27:38 +01:00 committed by GitHub
parent b2be5a703f
commit f308286484
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 118 additions and 3 deletions

View file

@ -16,6 +16,7 @@ import (
"github.com/autobrr/autobrr/internal/proxy"
"github.com/autobrr/autobrr/internal/release"
"github.com/autobrr/autobrr/pkg/errors"
"github.com/autobrr/autobrr/pkg/sanitize"
"github.com/dustin/go-humanize"
"github.com/mmcdole/gofeed"
@ -148,7 +149,7 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
}
if rls.DownloadURL == "" && item.Link != "" {
rls.DownloadURL = item.Link
rls.DownloadURL = sanitize.URLEncoding(item.Link)
}
if rls.DownloadURL != "" {
@ -158,8 +159,8 @@ func (j *RSSJob) processItem(item *gofeed.Item) *domain.Release {
if parentURL, _ := url.Parse(j.URL); parentURL != nil {
parentURL.Path, parentURL.RawPath = "", ""
// unescape the query params for max compatibility
escapedUrl, _ := url.QueryUnescape(parentURL.JoinPath(rls.DownloadURL).String())
downloadURL := sanitize.URLEncoding(rls.DownloadURL)
escapedUrl, _ := url.QueryUnescape(parentURL.JoinPath(downloadURL).String())
rls.DownloadURL = escapedUrl
}
}