Просмотр исходного кода

Merge pull request #1062 from slingamn/issue1057_ident

fix #1057
tags/v2.1.0
Shivaram Lingamneni 4 лет назад
Родитель
Сommit
98151ec7a5
Аккаунт пользователя с таким Email не найден
2 измененных файлов: 12 добавлений и 4 удалений
  1. 9
    3
      irc/handlers.go
  2. 3
    1
      irc/server.go

+ 9
- 3
irc/handlers.go Просмотреть файл

@@ -2503,12 +2503,18 @@ func userHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
2503 2503
 		return false
2504 2504
 	}
2505 2505
 
2506
-	err := client.SetNames(msg.Params[0], msg.Params[3], false)
2506
+	username, realname := msg.Params[0], msg.Params[3]
2507
+	if len(realname) == 0 {
2508
+		rb.Add(nil, server.name, ERR_NEEDMOREPARAMS, client.Nick(), client.t("Not enough parameters"))
2509
+		return false
2510
+	}
2511
+
2512
+	err := client.SetNames(username, realname, false)
2507 2513
 	if err == errInvalidUsername {
2508 2514
 		// if client's using a unicode nick or something weird, let's just set 'em up with a stock username instead.
2509 2515
 		// fixes clients that just use their nick as a username so they can still use the interesting nick
2510
-		if client.preregNick == msg.Params[0] {
2511
-			client.SetNames("user", msg.Params[3], false)
2516
+		if client.preregNick == username {
2517
+			client.SetNames("user", realname, false)
2512 2518
 		} else {
2513 2519
 			rb.Add(nil, server.name, ERR_INVALIDUSERNAME, client.Nick(), client.t("Malformed username"))
2514 2520
 		}

+ 3
- 1
irc/server.go Просмотреть файл

@@ -206,7 +206,9 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
206 206
 	}
207 207
 
208 208
 	// try to complete registration normally
209
-	if c.preregNick == "" || !c.HasUsername() || session.capState == caps.NegotiatingState {
209
+	// XXX(#1057) username can be filled in by an ident query without the client
210
+	// having sent USER: check for both username and realname to ensure they did
211
+	if c.preregNick == "" || c.username == "" || c.realname == "" || session.capState == caps.NegotiatingState {
210 212
 		return
211 213
 	}
212 214
 

Загрузка…
Отмена
Сохранить