mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 17:06:39 +09: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