diff options
author | Michael Muré <batolettre@gmail.com> | 2021-04-17 19:40:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-17 19:40:01 +0200 |
commit | 6d1c9346cc5ff892f808a7e3dd3e01291e49a16d (patch) | |
tree | 9b424181369a67f69502a27186bd266a19a28506 /identity/version.go | |
parent | 62fb09a53cc626ac581f33b466a1cdf14eb6ed89 (diff) | |
parent | 51a2c85954e77068c6afbb4ca54159086220aefd (diff) | |
download | git-bug-6d1c9346cc5ff892f808a7e3dd3e01291e49a16d.tar.gz |
Merge pull request #632 from MichaelMure/data-input-cleanup
make sure every text input is safe and validated
Diffstat (limited to 'identity/version.go')
-rw-r--r-- | identity/version.go | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/identity/version.go b/identity/version.go index 1c35831e..9a52d089 100644 --- a/identity/version.go +++ b/identity/version.go @@ -4,7 +4,6 @@ import ( "crypto/rand" "encoding/json" "fmt" - "strings" "time" "github.com/pkg/errors" @@ -186,25 +185,16 @@ func (v *version) Validate() error { if text.Empty(v.name) && text.Empty(v.login) { return fmt.Errorf("either name or login should be set") } - if strings.Contains(v.name, "\n") { - return fmt.Errorf("name should be a single line") - } - if !text.Safe(v.name) { - return fmt.Errorf("name is not fully printable") + if !text.SafeOneLine(v.name) { + return fmt.Errorf("name has unsafe characters") } - if strings.Contains(v.login, "\n") { - return fmt.Errorf("login should be a single line") - } - if !text.Safe(v.login) { - return fmt.Errorf("login is not fully printable") + if !text.SafeOneLine(v.login) { + return fmt.Errorf("login has unsafe characters") } - if strings.Contains(v.email, "\n") { - return fmt.Errorf("email should be a single line") - } - if !text.Safe(v.email) { - return fmt.Errorf("email is not fully printable") + if !text.SafeOneLine(v.email) { + return fmt.Errorf("email has unsafe characters") } if v.avatarURL != "" && !text.ValidUrl(v.avatarURL) { |