mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
strings: Prevent crash
This commit is contained in:
parent
c2fedfb177
commit
ea0121aeff
1 changed files with 5 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue