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:
parent
c2fedfb177
commit
ea0121aeff
@ -18,6 +18,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
errInvalidCharacter = errors.New("Invalid character")
|
errInvalidCharacter = errors.New("Invalid character")
|
||||||
|
errEmpty = errors.New("String is empty")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Casefold returns a casefolded string, without doing any name or channel character checks.
|
// 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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
} else if len(lowered) == 0 {
|
||||||
|
return "", errEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
if lowered[0] != '#' {
|
if lowered[0] != '#' {
|
||||||
@ -55,6 +58,8 @@ func CasefoldName(name string) (string, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
} else if len(lowered) == 0 {
|
||||||
|
return "", errEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
// space can't be used
|
// space can't be used
|
||||||
|
Loading…
Reference in New Issue
Block a user