summaryrefslogtreecommitdiff
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-26 21:26:33 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-27 13:25:56 +0100
commitf3e2e81d5385b9ffd84ed110d00eb347ec0e14f1 (patch)
tree522c2ad74abd4d6ac5eee6640fe1a31c4f0b42c8 /src/basic/string-util.c
parentf4f15635ec05293ffcc83a5b39f624bbabbd8fd0 (diff)
util: move string_is_safe() to string-util.[ch]
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index a7cf4e8520..a1781c505a 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -765,3 +765,20 @@ char *string_free_erase(char *s) {
string_erase(s);
return mfree(s);
}
+
+bool string_is_safe(const char *p) {
+ const char *t;
+
+ if (!p)
+ return false;
+
+ for (t = p; *t; t++) {
+ if (*t > 0 && *t < ' ') /* no control characters */
+ return false;
+
+ if (strchr(QUOTES "\\\x7f", *t))
+ return false;
+ }
+
+ return true;
+}