aboutsummaryrefslogtreecommitdiffstats
path: root/identity/version.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-04-17 17:40:11 +0200
committerMichael Muré <batolettre@gmail.com>2021-04-17 17:40:11 +0200
commit51a2c85954e77068c6afbb4ca54159086220aefd (patch)
tree9b424181369a67f69502a27186bd266a19a28506 /identity/version.go
parent62fb09a53cc626ac581f33b466a1cdf14eb6ed89 (diff)
downloadgit-bug-51a2c85954e77068c6afbb4ca54159086220aefd.tar.gz
make sure every text input is safe and validated
fix #630
Diffstat (limited to 'identity/version.go')
-rw-r--r--identity/version.go22
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) {