systemd::escape_unit - allow '.' and '_'

This commit is contained in:
Dietmar Maurer 2020-10-21 10:36:25 +02:00
parent 53a561a222
commit 030c5c6d8a

View File

@ -25,7 +25,12 @@ pub fn escape_unit(mut unit: &str, is_path: bool) -> String {
escaped.push('-');
continue;
}
if (i == 0 && *c == b'.') || !((*c >= b'0' && *c <= b'9') || (*c >= b'A' && *c <= b'Z') || (*c >= b'a' && *c <= b'z')) {
if (i == 0 && *c == b'.')
|| !(*c == b'_' ||
*c == b'.' ||
(*c >= b'0' && *c <= b'9') ||
(*c >= b'A' && *c <= b'Z') ||
(*c >= b'a' && *c <= b'z')) {
escaped.push_str(&format!("\\x{:0x}", c));
} else {
escaped.push(*c as char);