aboutsummaryrefslogtreecommitdiffstats
path: root/util/text/validate.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 /util/text/validate.go
parent62fb09a53cc626ac581f33b466a1cdf14eb6ed89 (diff)
downloadgit-bug-51a2c85954e77068c6afbb4ca54159086220aefd.tar.gz
make sure every text input is safe and validated
fix #630
Diffstat (limited to 'util/text/validate.go')
-rw-r--r--util/text/validate.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/text/validate.go b/util/text/validate.go
index 51e94fb4..4c3f7065 100644
--- a/util/text/validate.go
+++ b/util/text/validate.go
@@ -33,6 +33,18 @@ func Safe(s string) bool {
return true
}
+// Safe will tell if a character in the string is considered unsafe
+// Currently trigger on all unicode control character
+func SafeOneLine(s string) bool {
+ for _, r := range s {
+ if unicode.IsControl(r) {
+ return false
+ }
+ }
+
+ return true
+}
+
// ValidUrl will tell if the string contains what seems to be a valid URL
func ValidUrl(s string) bool {
if strings.Contains(s, "\n") {