[systemd-devel] DBus service name encoding

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Mar 4 11:00:59 PST 2013


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.

    S


More information about the systemd-devel mailing list