Re: XML escaping patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 06, 2007 at 03:05:09PM +0100, Richard W.M. Jones wrote:
> Daniel Veillard wrote:
> [...]
> > /**
> >+ * virBufferEscapeString:
> >+ * @buf:  the buffer to dump
> >+ * @format: a printf like format string but with only one %s parameter
> >+ * @str:  the string argument which need to be escaped
> >+ *
> >+ * Do a formatted print with a single string to an XML buffer. The string
> >+ * is escaped to avoid generating a not well-formed XML instance.
> >+ *
> >+ * Returns 0 successful, -1 in case of internal or API error.
> >+ */
> >+int
> >+virBufferEscapeString(virBufferPtr buf, const char *format, const char 
> >*str)
> 
> I spent a bit of time pondering if it would be possible to either make 
> this call type-safe, or else handle arbitrary format strings.  I'm not 
> sure I can see a good way to do either, so in the meantime, +1.

If we want safety then we should be using an API based on structural
notion of XML elements & attributes, rather than printf. In our use
cases any single attribute / element is either a boolean, int or a
string, so if we had APIs based on idea of creating elements / adding
attributes the whole thing could be typesafe & have no need of any
printf formatting.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]