flashmob / go-guerrilla

Mini SMTP server written in golang
MIT License
2.79k stars 366 forks source link

trimToLimit does not work with utf-8 encoding #209

Open 4k7 opened 4 years ago

4k7 commented 4 years ago

Hi,

trimToLimit function (in file p_guerrilla_db_redis.go) does not work with utf-8 encoding. This function is also used in the file p_sql.go.

It should be like this to correct operation.

func trimToLimit(str string, limit int) string {
    ret := strings.TrimSpace(str)
    if len([]rune(str)) > limit {
        ret = string([]rune(str)[:limit])
    }
    return ret
}

Thanks.

flashmob commented 4 years ago

Thanks!