Re: [xml] xmlEncodeEntitiesReentrant



On Tue, Sep 06, 2011 at 10:15:00AM +0200, Jeroen Lamain wrote:
Hi,

I'm using xmlEncodeEntitiesReentrant to encode some strings to
proper xml strings.
Now I noticed that double quotes are not quoted correcly.
I downloaded the source of libxml2-2.7.8 and looked in the
xmlEncodeEntitiesReentrant function.

There I see:(line 584)
/*
     * By default one have to encode at least '<', '>', '"' and '&' !
     */
    if (*cur == '<') {
        *out++ = '&';
        *out++ = 'l';
        *out++ = 't';
        *out++ = ';';
    } else if (*cur == '>') {
        *out++ = '&';
        *out++ = 'g';
        *out++ = 't';
        *out++ = ';';
    } else if (*cur == '&') {
        *out++ = '&';
        *out++ = 'a';
        *out++ = 'm';
        *out++ = 'p';
        *out++ = ';';
    } else if (((*cur >= 0x20) && (*cur < 0x80)) ||
        (*cur == '\n') || (*cur == '\t') || ((html) && (*cur == '\r'))) {
        /*
         * default case, just copy !
         */
        *out++ = *cur;
    }


It seems the comment says " char must be quoted, but the code is not there ?
Or am I doing something wrong ?

  The comment is wrong, in general " doesn't have to be quoted except in
attribute values, but then ' can be used instead to delimit the
attribute content. I think the earlier version was fixed as libxml2
serializer for attributes was improved later,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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