mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
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:
parent
b2be5a703f
commit
f308286484
3 changed files with 118 additions and 3 deletions
|
@ -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", ",")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue