summaryrefslogtreecommitdiff
path: root/src/basic/string-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/string-util.c')
-rw-r--r--src/basic/string-util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index a7cf4e8520..63b9b79df9 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -19,6 +19,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "alloc-util.h"
#include "gunicode.h"
#include "utf8.h"
#include "util.h"
@@ -765,3 +766,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;
+}