diff options
author | mrsdizzie <info@mrsdizzie.com> | 2020-05-29 12:08:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 17:08:36 +0100 |
commit | 4c1ff57f1a41197bb6f6797d33461c76378e354c (patch) | |
tree | 5f1fc2fa51ccfefe937353c036b76566712f0fd5 /modules/markup/html.go | |
parent | 02fa329a7c2190d947cd5e02ea90d2d4406653be (diff) | |
download | gitea-4c1ff57f1a41197bb6f6797d33461c76378e354c.tar.gz gitea-4c1ff57f1a41197bb6f6797d33461c76378e354c.zip |
Update emoji regex (#11584)
When matching emoji, use a regex built from the data we have instead of something generic using unicode ranges. A generic regex can't tell the difference between two separate emoji next to each other or one emoji that is built out of two separate emoji next to each other.
This means that emoji that are next to each other without space in between will be now accurately spanned individually with proper title etc...
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r-- | modules/markup/html.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go index 8fbfee6a53..41248654d8 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -65,10 +65,6 @@ var ( // EmojiShortCodeRegex find emoji by alias like :smile: EmojiShortCodeRegex = regexp.MustCompile(`\:[\w\+\-]+\:{1}`) - - // find emoji literal: search all emoji hex range as many times as they appear as - // some emojis (skin color etc..) are just two or more chained together - emojiRegex = regexp.MustCompile(`[\x{1F000}-\x{1FFFF}|\x{2000}-\x{32ff}|\x{fe4e5}-\x{fe4ee}|\x{200D}|\x{FE0F}|\x{e0000}-\x{e007f}]+`) ) // CSS class for action keywords (e.g. "closes: #1") @@ -922,8 +918,7 @@ func emojiShortCodeProcessor(ctx *postProcessCtx, node *html.Node) { // emoji processor to match emoji and add emoji class func emojiProcessor(ctx *postProcessCtx, node *html.Node) { - m := emojiRegex.FindStringSubmatchIndex(node.Data) - + m := emoji.FindEmojiSubmatchIndex(node.Data) if m == nil { return } |