From 9b38ea70689c3345b96ba486e1afc20b7a3d86e3 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 5 Nov 2024 16:03:32 +0100 Subject: [PATCH] Betterify sanitization --- downloader/download_downloadr.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/downloader/download_downloadr.go b/downloader/download_downloadr.go index c44f796..368528b 100644 --- a/downloader/download_downloadr.go +++ b/downloader/download_downloadr.go @@ -6,6 +6,7 @@ import ( "log" "os" "path/filepath" + "regexp" "strings" "github.com/gen2brain/beeep" @@ -78,11 +79,10 @@ func DownloadR(url string) error { return nil } +var re = regexp.MustCompile(`[#!$%&/()";:?;,]`) + func Sanitize(s string) string { s = strings.ReplaceAll(s, "&", "and") - s = strings.ReplaceAll(s, "?", "") - s = strings.ReplaceAll(s, ":", "") - s = strings.ReplaceAll(s, ";", "") - s = strings.ReplaceAll(s, ",", "") + s = re.ReplaceAllString(s, "") return s }