mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
util: move string_is_safe() to string-util.[ch]
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user