From 494317e4f4c22777e32de4e36a178a1c030cd473 Mon Sep 17 00:00:00 2001 From: Mat Kelly Date: Mon, 15 Apr 2024 15:27:49 -0400 Subject: [PATCH 1/5] Handles escaped URI-Rs Closes #110 --- main.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 320dbcd..1018c42 100644 --- a/main.go +++ b/main.go @@ -472,13 +472,17 @@ func aggregateTimemap(urir string, dttmp *time.Time, sess *Session) (basetm *lis } func parseURI(uri string) (urir string, err error) { - if !regs["isprtcl"].MatchString(uri) { - uri = "http://" + uri + uescd, err := url.QueryUnescape(uri) + if !regs["isprtcl"].MatchString(uescd) { + uescd = "http://" + uri } - u, err := url.Parse(uri) + + u, err := url.Parse(uescd) + if err == nil { urir = u.String() } + return } From be78613605b255f4815fd919d9b6201cacafad5c Mon Sep 17 00:00:00 2001 From: Mat Kelly Date: Mon, 15 Apr 2024 21:13:59 -0400 Subject: [PATCH 2/5] Use Path unescape instead of query for #146. Fix the var in the first conditional per @ibnesayeed --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 1018c42..3e0f5d3 100644 --- a/main.go +++ b/main.go @@ -472,9 +472,9 @@ func aggregateTimemap(urir string, dttmp *time.Time, sess *Session) (basetm *lis } func parseURI(uri string) (urir string, err error) { - uescd, err := url.QueryUnescape(uri) + uescd, err := url.PathUnescape(uri) if !regs["isprtcl"].MatchString(uescd) { - uescd = "http://" + uri + uescd = "http://" + uescd } u, err := url.Parse(uescd) From ae707adba071566faa3494da43e7ce4d7fe4f749 Mon Sep 17 00:00:00 2001 From: Mat Kelly Date: Tue, 16 Apr 2024 13:47:28 -0400 Subject: [PATCH 3/5] Add error handling for unescaping path --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 3e0f5d3..83b537d 100644 --- a/main.go +++ b/main.go @@ -473,6 +473,12 @@ func aggregateTimemap(urir string, dttmp *time.Time, sess *Session) (basetm *lis func parseURI(uri string) (urir string, err error) { uescd, err := url.PathUnescape(uri) + + if err != nil { + logError.Printf("Error Unescaping path (%s): %v", uri, err) + return + } + if !regs["isprtcl"].MatchString(uescd) { uescd = "http://" + uescd } From ee2ed0d47362f87fdc41156cf0bdf7dcc54f0e25 Mon Sep 17 00:00:00 2001 From: Mat Kelly Date: Wed, 17 Apr 2024 10:38:18 -0400 Subject: [PATCH 4/5] Rm blank lines to match style --- main.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/main.go b/main.go index 83b537d..c839ab2 100644 --- a/main.go +++ b/main.go @@ -473,22 +473,17 @@ func aggregateTimemap(urir string, dttmp *time.Time, sess *Session) (basetm *lis func parseURI(uri string) (urir string, err error) { uescd, err := url.PathUnescape(uri) - if err != nil { logError.Printf("Error Unescaping path (%s): %v", uri, err) return } - if !regs["isprtcl"].MatchString(uescd) { uescd = "http://" + uescd } - u, err := url.Parse(uescd) - if err == nil { urir = u.String() } - return } From e6e7820cab4a5a75179c26f922d1eeb81a475a41 Mon Sep 17 00:00:00 2001 From: Mat Kelly Date: Wed, 17 Apr 2024 14:55:46 -0400 Subject: [PATCH 5/5] Handle spaces in URI-R Co-authored-by: Mat Kelly Co-authored-by: Sawood Alam --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index c839ab2..88ba247 100644 --- a/main.go +++ b/main.go @@ -477,6 +477,7 @@ func parseURI(uri string) (urir string, err error) { logError.Printf("Error Unescaping path (%s): %v", uri, err) return } + uescd = strings.ReplaceAll(uescd, " ", "%20") if !regs["isprtcl"].MatchString(uescd) { uescd = "http://" + uescd }