@@ -68,17 +68,31 @@ var (
68
68
69
69
// ValidateAIMHandle returns an error if the instance is not a valid AIM screen name.
70
70
// Possible errors:
71
- // - ErrAIMHandleLength: if the screen name is not between 3 and 16
72
- // characters
71
+ // - ErrAIMHandleLength: if the screen name has less than 3 non-space
72
+ // characters or more than 16 characters (including spaces).
73
73
// - ErrAIMHandleInvalidFormat: if the screen name does not start with a
74
74
// letter, ends with a space, or contains invalid characters
75
75
func (s DisplayScreenName ) ValidateAIMHandle () error {
76
- if len (s ) < 3 || len ( s ) > 16 {
76
+ if len (s ) > 16 {
77
77
return ErrAIMHandleLength
78
78
}
79
79
80
- // Must start with a letter, cannot end with a space,
81
- // and must contain only letters, numbers, and spaces
80
+ // Must contain at least 3 letters.
81
+ c := 0
82
+ for _ , r := range s {
83
+ if unicode .IsLetter (r ) {
84
+ c ++
85
+ }
86
+ if c == 3 {
87
+ break
88
+ }
89
+ }
90
+ if c < 3 {
91
+ return ErrAIMHandleLength
92
+ }
93
+
94
+ // Must start with a letter, cannot end with a space, and must contain only
95
+ // letters, numbers, and spaces.
82
96
if ! unicode .IsLetter (rune (s [0 ])) || s [len (s )- 1 ] == ' ' {
83
97
return ErrAIMHandleInvalidFormat
84
98
}
@@ -173,9 +187,8 @@ func (u *User) HashPassword(passwd string) error {
173
187
}
174
188
175
189
// validateAIMPassword returns an error if the AIM password is invalid.
176
- // A valid password is 4-16 characters long. The minimum password length is
177
- // set here for software preservation purposes; operators should set more
178
- // stringent password requirements.
190
+ // A valid password is 4-16 characters long. The min and max password length
191
+ // values reflect AOL's password validation rules circa 2000.
179
192
func validateAIMPassword (pass string ) error {
180
193
if len (pass ) < 4 || len (pass ) > 16 {
181
194
return errors .New ("password length must be between 4-16 characters" )
@@ -184,12 +197,12 @@ func validateAIMPassword(pass string) error {
184
197
}
185
198
186
199
// validateICQPassword returns an error if the ICQ password is invalid.
187
- // A valid password is 1 -8 characters long. The minimum password length is set
188
- // here for software preservation purposes; operators should set more stringent
189
- // password requirements .
200
+ // A valid password is 6 -8 characters long. It's unclear what min length the
201
+ // ICQ service required, so a plausible minimum value is set. The max length
202
+ // reflects the password limitation imposed by old ICQ clients .
190
203
func validateICQPassword (pass string ) error {
191
- if len (pass ) < 1 || len (pass ) > 8 {
192
- return errors .New ("password must be between 1 and 8 characters" )
204
+ if len (pass ) < 6 || len (pass ) > 8 {
205
+ return errors .New ("password must be between 6 and 8 characters" )
193
206
}
194
207
return nil
195
208
}
0 commit comments