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

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


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