Skip to content

Commit f9b5519

Browse files
committed
Escape app name when sending to systemd
1 parent e31df4a commit f9b5519

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/AppSystem/App.vala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,18 @@ public class Dock.App : Object {
199199
}
200200
}
201201

202+
var string_builder = new StringBuilder.sized (app_name.length);
203+
for (var i = 0; i < app_name.length; i++) {
204+
var c = app_name[i];
205+
if (c.isalnum () || c == ':' || c == '_' || c == '.') {
206+
string_builder.append_c (c);
207+
} else {
208+
string_builder.append_printf ("\\x%02x", c);
209+
}
210+
}
211+
202212
var builder = new VariantBuilder (new VariantType ("(ssa(sv)a(sa(sv)))"));
203-
builder.add ("s", "app-pantheon-%s-%d.scope".printf (app_name, pid));
213+
builder.add ("s", "app-pantheon-%s-%d.scope".printf (string_builder.free_and_steal (), pid));
204214
builder.add ("s", "fail");
205215

206216
builder.open (new VariantType ("a(sv)"));

0 commit comments

Comments
 (0)