From 4eeb9ec743270e864751dd51e5be5182dc16a461 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 3 Jul 2019 16:06:31 -0400 Subject: [PATCH] don't let html entities leak as hashtags --- fun.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fun.go b/fun.go index a044e84..1dd348f 100644 --- a/fun.go +++ b/fun.go @@ -122,12 +122,18 @@ var re_hashes = regexp.MustCompile(`(?:^|\W)#[[:alnum:]]+`) func ontologies(s string) []string { m := re_hashes.FindAllString(s, -1) - for i, h := range m { - if h[0] != '#' { - m[i] = h[1:] + j := 0 + for _, h := range m { + if h[0] == '&' { + continue } + if h[0] != '#' { + h = h[1:] + } + m[j] = h + j++ } - return m + return m[:j] } type Mention struct {