From freedesktop-dbus Thu Jun 15 19:21:00 2006 From: Thiago Macieira Date: Thu, 15 Jun 2006 19:21:00 +0000 To: freedesktop-dbus Subject: Re: Escaping for paths Message-Id: <200606152121.00492.thiago.macieira () trolltech ! com> X-MARC-Message: https://marc.info/?l=freedesktop-dbus&m=117323265230781 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--nextPart2520434.9zQXfb8pgh" --nextPart2520434.9zQXfb8pgh Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ross Burton wrote: >Hi, > >Several applications are writing methods to escape strings so that they >can be used in object paths (specifically Network Manager does this, and >eds-dbus has taken code from NM too). EDS is using it so that it can >return an object path of the >form /org/gnome/evolution/addressbook/[uri], where obviously the URI >needs to be escaped. > >I think it would be useful for DBus to contain a function that escaped >an arbitrary string so that it could be used in an object path to avoid >this needless wheel re-inventing. Anyone else agree? I discussed this very issue with another developer yesterday. The issue in= =20 question was bookmarks instead of addressbooks, but it's exactly the same=20 use-case. My conclusion is that we should not provide such a generic method. I=20 believe it's dangerous. I'd much rather see the applications internally=20 changed to avoid this kind of problem. In this example, what I would instead propose is that the object=20 at /org/gnome/evolution/addressbook provide a method called "FindURI" or=20 something similar, which would take the URI and return an object path to=20 the internal object. This would have the added benefit of on-demand=20 loading, since there's a call before the actual object access. I also don't believe this kind of functionality belongs in the core=20 library. Validation? Yes. Escaping? I don't think so. The reason why I think it's dangerous is that two different URIs or=20 pathnames could escape to the same object path. For example, imagine I=20 had addressbooks: /home/thiago/address_book-vcf /home/thiago/address_book.vcf (that's a Greek alpha and a Greek beta) Both would escape to /home/thiago/address_book_vcf or=20 _home_thiago_addres_book_vcf.=20 The only solution would be to select one of the characters we have to be=20 an escape character, like % in URIs. The above example would=20 be /home/thiago/address_5fbook_2dvcf=20 and /home/thiago/address_5fbook_2evcf, or=20 _2fhome_2fthiago_2faddress_5fbook_2dvcf and=20 _2fhome_2fthiago_2faddress_5fbook_2evcf. If people push arbitrary data=20 into this function, it would have the potential to increase the length=20 threefold. Or to completely escape everything (yielding something ugly like:=20 _2f686f6d652f74686961676f2f61646472657373626f6f6b2e7663660a) =2D-=20 Thiago Jos=C3=A9 Macieira - thiago.macieira AT trolltech.com Trolltech ASA - Sandakerveien 116, NO-0402 Oslo, Norway --nextPart2520434.9zQXfb8pgh Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQBEkbMcM/XwBW70U1gRAmm7AKCH31rGZysAiDYuv1cbaNwpI5CQsQCguzZV eP98Zp2qUTvis0hfCrxa7HA= =lPlf -----END PGP SIGNATURE----- --nextPart2520434.9zQXfb8pgh--