From 9aeb813cf5b072feaca06a4d846e925fd408c0f9 Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Wed, 26 Feb 2014 13:20:41 -0800 Subject: [PATCH] restrict nicknames to proper character set --- irc/constants.go | 6 +++--- irc/server.go | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/irc/constants.go b/irc/constants.go index 49bf4c93..20e07b17 100644 --- a/irc/constants.go +++ b/irc/constants.go @@ -17,13 +17,13 @@ var ( ErrAlreadyDestroyed = errors.New("already destroyed") // regexps - ChannelNameExpr = regexp.MustCompile(`^[&!#+][[:word:]]{1,63}$`) + ChannelNameExpr = regexp.MustCompile(`^[&!#+][\pL\pN]{1,63}$`) NicknameExpr = regexp.MustCompile( - "^[[:alpha:]\\[\\]{}^`][[:word:]\\[\\]{}^`]{1,31}$") + "^[\\pL\\[\\]{}^`][\\pL\\pN\\[\\]{}^`]{1,31}$") ) const ( - SEM_VER = "ergonomadic-1.2.6" + SEM_VER = "ergonomadic-1.2.7" CRLF = "\r\n" MAX_REPLY_LEN = 512 - len(CRLF) diff --git a/irc/server.go b/irc/server.go index e9a4d45c..49c5f4ad 100644 --- a/irc/server.go +++ b/irc/server.go @@ -407,6 +407,11 @@ func (msg *NickCommand) HandleServer(server *Server) { return } + if !IsNickname(msg.nickname) { + client.ErrErroneusNickname(msg.nickname) + return + } + if msg.nickname == client.nick { return }