Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: exclude all punctuation chars except underscore in tags (#1974)
Felipe Martínez8c6153167181
diff --git a/api/v1/tag.go b/api/v1/tag.goindex acd8407b4..3bf6e39f7 100644--- a/api/v1/tag.go+++ b/api/v1/tag.go@@ -176,7 +176,7 @@ func convertTagFromStore(tag *store.Tag) *Tag {}}-var tagRegexp = regexp.MustCompile(`#([^\s#,]+)`)+var tagRegexp = regexp.MustCompile(`#((?:[^\s\p{P}]|_)+)`)func findTagListFromMemoContent(memoContent string) []string {tagMapSet := make(map[string]bool)diff --git a/api/v1/tag_test.go b/api/v1/tag_test.goindex 10578aab3..791d83db4 100644--- a/api/v1/tag_test.go+++ b/api/v1/tag_test.go@@ -2,6 +2,8 @@ package v1import ("testing"++ "golang.org/x/exp/slices")func TestFindTagListFromMemoContent(t *testing.T) {@@ -35,12 +37,16 @@ func TestFindTagListFromMemoContent(t *testing.T) {},{memoContent: "#tag1 http://123123.com?123123#tag2 \n#tag3 #tag4 http://123123.com?123123#tag2) ",- want: []string{"tag1", "tag2", "tag2)", "tag3", "tag4"},+ want: []string{"tag1", "tag2", "tag3", "tag4"},+ },+ {+ memoContent: "#tag1,#tag2! #tag3.. #tag_4",+ want: []string{"tag1", "tag2", "tag3", "tag_4"},},}for _, test := range tests {result := findTagListFromMemoContent(test.memoContent)- if len(result) != len(test.want) {+ if !slices.Equal(result, test.want) {t.Errorf("Find tag list %s: got result %v, want %v.", test.memoContent, result, test.want)}}diff --git a/web/src/labs/marked/parser/Tag.tsx b/web/src/labs/marked/parser/Tag.tsxindex 95e197a8a..d7f2b967d 100644--- a/web/src/labs/marked/parser/Tag.tsx+++ b/web/src/labs/marked/parser/Tag.tsx@@ -1,6 +1,6 @@import { matcher } from "../matcher";-export const TAG_REG = /#([^\s#,]+)/;+export const TAG_REG = /#((?:[^\s\p{P}]|_)+)/u;const renderer = (rawStr: string) => {const matchResult = matcher(rawStr, TAG_REG);