[libvirt] [PATCH] XML: Escape double-hyphens in XML comment

Eric Blake eblake at redhat.com
Fri Feb 21 17:24:53 UTC 2014


On 02/21/2014 02:01 AM, Philipp Hahn wrote:
> To quote <http://www.w3.org/TR/REC-xml/#sec-comments>:
>> For compatibility, the string "--" (double-hyphen) must not occur within comments.
> 

>  
> +/*
> + * Break sequence of hyphens by inserting (arbitrarily chosen) backslashes.
> + * <http://www.w3.org/TR/REC-xml/#sec-comments>:
> + * > For compatibility, the string "--" (double-hyphen) must not occur within
> + * > comments.
> + */
> +static int virXMLEmitEscapedComment(int fd,
> +                                    const char *str)
> +{
> +    size_t len;
> +
> +    if (!strstr(str, "--")) {
> +        len = strlen(str);
> +        if (safewrite(fd, str, len) != len)
> +            return -1;
> +        return 0;
> +    }
> +
> +    for (;*str;str++) {

Style: spaces after ';'.

This would also be a perfect candidate for Dan's virStringReplace patch,
rather than open-coding your own replacement loop.

That, and Jan already pointed out better patches to be backported :)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140221/ccc2a9e1/attachment-0001.sig>


More information about the libvir-list mailing list