[systemd-devel] DBus service name encoding
lennart at poettering.net
Tue Mar 5 11:01:41 PST 2013
On Mon, 04.03.13 19:00, Simon McVittie (simon.mcvittie at collabora.co.uk) wrote:
> On 04/03/13 14:31, Lennart Poettering wrote:
> > So here's how to do this, it's very simple: every char outside of the
> > A-Za-z0-9 range is escaped as "_XY" where XY is the numeric code of the
> > char, as 2 char lower-case hex value. Note that "_" itself is also
> > escaped, to "_5f".
> This sounds a lot like Telepathy's tp_escape_as_identifier(). Before
> freezing this as ABI, you might want to consider a couple of the more
> subtle points from that function:
> * we also escape any leading digit in the same way, so that a name
> starting with a digit is escaped as a valid bus name component
> ("123.service" -> "_3123_2eservice", because the D-Bus specification
> says "Only elements that are part of a unique connection name may
> begin with a digit")
> * for completeness, we also escape "" into "_" (because a zero-length
> string is not a valid D-Bus name component)
> This results in its output being a valid D-Bus bus-name element,
> interface-name element, member, and object-path element, and also a
> valid C identifier.
Thanks for the suggestions! I have now updated systemd to follow the
same logic in these corner cases. I also added test cases so that this
should be pretty much set in stone now.
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel