fix reaction's name validation with + sign in it (#6221)

This commit is contained in:
Saturnino Abril
2017-04-26 23:11:32 +09:00
committed by Harrison Healey
parent f9502ff14b
commit 6fa7082833
5 changed files with 62 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ package api4
import (
"fmt"
"net/http"
"regexp"
"strings"
"time"
@@ -504,7 +505,9 @@ func (c *Context) RequireEmojiName() *Context {
return c
}
if len(c.Params.EmojiName) == 0 || len(c.Params.EmojiName) > 64 || !model.IsValidAlphaNumHyphenUnderscore(c.Params.EmojiName, false) {
validName := regexp.MustCompile(`^[a-zA-Z0-9\-\+_]+$`)
if len(c.Params.EmojiName) == 0 || len(c.Params.EmojiName) > 64 || !validName.MatchString(c.Params.EmojiName) {
c.SetInvalidUrlParam("emoji_name")
}