aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <=>2021-02-23 19:21:43 -0800
committerFChannel <=>2021-02-23 19:21:43 -0800
commitbbb1b82c5b5bc9c7e9cd96c41aa8339a95e49864 (patch)
tree74b4a5277a2a5fd4da7565777efafec2db0d53b1 /main.go
parent28e256f18f96d9afdcb903b3bc3daf93747c2195 (diff)
added fix for special characters in board name, also escaped some characters for regex. might be some missing edge cases
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/main.go b/main.go
index 58e8f3d..6383aaf 100644
--- a/main.go
+++ b/main.go
@@ -118,11 +118,19 @@ func main() {
actorReported = (path == "/" + actor.Name + "/reported")
actorVerification = (path == "/" + actor.Name + "/verification")
- re := regexp.MustCompile("/" + actor.Name + "/[0-9]{1,2}$")
+ escapedActorName := strings.Replace(actor.Name, "*", "\\*", -1)
+ escapedActorName = strings.Replace(escapedActorName, "^", "\\^", -1)
+ escapedActorName = strings.Replace(escapedActorName, "$", "\\$", -1)
+ escapedActorName = strings.Replace(escapedActorName, "?", "\\?", -1)
+ escapedActorName = strings.Replace(escapedActorName, "+", "\\+", -1)
+ escapedActorName = strings.Replace(escapedActorName, ".", "\\.", -1)
+
+ re := regexp.MustCompile("/" + escapedActorName + "/[0-9]{1,2}$")
actorMainPage = re.MatchString(path)
- re = regexp.MustCompile("/" + actor.Name + "/\\w+")
+ re = regexp.MustCompile("/" + escapedActorName + "/\\w+")
+
actorPost = re.MatchString(path)
}