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

@ -12,6 +12,30 @@ func String(str string) string {
return str
}
func URLEncoding(str string) string {
replacements := []struct {
old string
new string
}{
{`\u0026`, "&"},
{`\u003d`, "="},
{`\u003f`, "?"},
{`\u002f`, "/"},
{`\u003a`, ":"},
{`\u0023`, "#"},
{`\u0040`, "@"},
{`\u0025`, "%"},
{`\u002b`, "+"},
}
for _, r := range replacements {
str = repeatedReplaceAll(str, r.old, r.new)
}
str = strings.TrimSpace(str)
return str
}
func FilterString(str string) string {
// replace newline with comma
str = strings.ReplaceAll(str, "\r", ",")