Skip to content
Permalink
Browse files

Restrict usernames from containing spaces at the beginning or end of …

…the name.
  • Loading branch information...
Shinmera committed Aug 14, 2018
1 parent 12c27fa commit c0d2a4fc4689fea9a5a7bf0ccc7b7860c195b59c
Showing with 6 additions and 3 deletions.
  1. +2 −1 README.md
  2. +1 −1 lichat-protocol.asd
  3. +3 −1 protocol.lisp
@@ -42,7 +42,8 @@ Each client is connected to the server through a `connection` object. Each conne
`user`s represent participants on the chat network. A user has a globally unique name and a number of connections that can act as the user. Each user can be active in a number of channels, the maximal number of which is implementation-dependant. A user must always inhabit the primary channel. A user may have a profile object associated with it. When such a profile exists, the user is considered to be "registered." The server itself must also have an associated user object, the name of which is up to the specific server instance.

##### 2.2.1 User Name Constraints
A user's name must be between 1 and 32 characters long, where each character must be from the Unicode general categories Letter, Mark, Number, Punctuation, and Symbol, or be a Space (`U+0020`).
A user's name must be between 1 and 32 characters long, where each character must be from the Unicode general categories Letter, Mark, Number, Punctuation, and Symbol, or be a Space (`U+0020`). The name must not begin or end with
with Spaces (`U+0020`).

#### 2.3 Profile
The `profile` primarily exists to allow end-users to log in to a user through a password and thus secure the username from being taken by others. A profile has a maximal lifetime. If the user associated with the profile has not been used for longer than the profile's lifetime, the profile is deleted.
@@ -5,7 +5,7 @@
|#

(asdf:defsystem lichat-protocol
:version "1.3"
:version "1.4"
:license "Artistic"
:author "Nicolas Hafner <shinmera@tymoon.eu>"
:maintainer "Nicolas Hafner <shinmera@tymoon.eu>"
@@ -63,7 +63,9 @@
(defun username-p (name)
(and (stringp name)
(<= 1 (length name) 32)
(every #'valid-name-char-p name)))
(every #'valid-name-char-p name)
(char/= #\Space (char name 0))
(char/= #\Space (char name (1- (length name))))))

(deftype username ()
`(satisfies username-p))

0 comments on commit c0d2a4f

Please sign in to comment.
You can’t perform that action at this time.