3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

strings: Prevent crash

This commit is contained in:
Daniel Oaks 2017-01-22 12:44:05 +10:00
parent c2fedfb177
commit ea0121aeff

View File

@ -18,6 +18,7 @@ const (
var (
errInvalidCharacter = errors.New("Invalid character")
errEmpty = errors.New("String is empty")
)
// Casefold returns a casefolded string, without doing any name or channel character checks.
@ -31,6 +32,8 @@ func CasefoldChannel(name string) (string, error) {
if err != nil {
return "", err
} else if len(lowered) == 0 {
return "", errEmpty
}
if lowered[0] != '#' {
@ -55,6 +58,8 @@ func CasefoldName(name string) (string, error) {
if err != nil {
return "", err
} else if len(lowered) == 0 {
return "", errEmpty
}
// space can't be used