From 213683bf7245a05aa734ac2bb26fba60705ba5ee Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Thu, 22 Jul 2021 16:08:51 -0700 Subject: regex escape hyphens in regex for quote and replies --- client.go | 4 +--- main.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 5d824bf..f47ca52 100644 --- a/client.go +++ b/client.go @@ -10,7 +10,6 @@ import ( "sort" "regexp" "time" - "fmt" ) var Key *string = new(string) @@ -635,7 +634,6 @@ func MediaProxy(url string) string { return url } - fmt.Println("") MediaHashs[HashMedia(url)] = url return "/api/media?hash=" + HashMedia(url) } @@ -643,7 +641,7 @@ func MediaProxy(url string) string { func ParseContent(db *sql.DB, board Actor, op string, content string, thread ObjectBase) template.HTML { var nContent = content - re := regexp.MustCompile(`(>>https?:\/\/[A-Za-z0-9_.-~]+\/[A-Za-z0-9_.-~]+\/\w+)`) + re := regexp.MustCompile(`(>>https?://[A-Za-z0-9_.\-~]+\/[A-Za-z0-9_.\-~]+\/\w+)`) match := re.FindAllStringSubmatch(nContent, -1) //add url to each matched reply diff --git a/main.go b/main.go index 60f537f..9ef9873 100644 --- a/main.go +++ b/main.go @@ -1649,7 +1649,7 @@ func CreateAttachmentObject(file multipart.File, header *multipart.FileHeader) ( func ParseCommentForReplies(comment string) []ObjectBase { - re := regexp.MustCompile(`(>>https?:\/\/[A-z.:0-9]+\/[A-z0-9]+\/\w+)`) + re := regexp.MustCompile(`(>>https?://[A-Za-z0-9_.\-~]+\/[A-Za-z0-9_.\-~]+\/\w+)`) match := re.FindAllStringSubmatch(comment, -1) var links []string -- cgit v1.2.3