From ecb10ed62fdff179e34f82b0ff2569da8390f4ad Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 22 Apr 2017 21:52:03 +0900 Subject: APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name (#6117) * APIv4 DELETE /users/{user_id}/posts/{post_id}/reactions/name * updated v3 deleteReaction endpoint * update parameter of app.DeleteReactionForPost() * update utils.IsValidAlphaNum, add utils.IsValidAlphaNumHyphenUnderscore, and add related tests --- api4/context.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'api4/context.go') diff --git a/api4/context.go b/api4/context.go index f492f2b99..c7fba4f5f 100644 --- a/api4/context.go +++ b/api4/context.go @@ -468,7 +468,7 @@ func (c *Context) RequireCategory() *Context { return c } - if !model.IsValidAlphaNum(c.Params.Category, true) { + if !model.IsValidAlphaNumHyphenUnderscore(c.Params.Category, true) { c.SetInvalidUrlParam("category") } @@ -492,13 +492,25 @@ func (c *Context) RequirePreferenceName() *Context { return c } - if !model.IsValidAlphaNum(c.Params.PreferenceName, true) { + if !model.IsValidAlphaNumHyphenUnderscore(c.Params.PreferenceName, true) { c.SetInvalidUrlParam("preference_name") } return c } +func (c *Context) RequireEmojiName() *Context { + if c.Err != nil { + return c + } + + if len(c.Params.EmojiName) == 0 || len(c.Params.EmojiName) > 64 || !model.IsValidAlphaNumHyphenUnderscore(c.Params.EmojiName, false) { + c.SetInvalidUrlParam("emoji_name") + } + + return c +} + func (c *Context) RequireHookId() *Context { if c.Err != nil { return c -- cgit v1.2.3-1-g7c22