xml_print_node has some problem in processing empy attribute

Q
qiulang
Tue, Jun 21, 2016 10:01 AM

I thinkxml_print_node has some problem in processing empy attribute, e.g. x attributeA= “” … /x, here attributeA has an empty value

So in code

/* Attribute name. */
pj_memcpy(p, attr-name.ptr, attr-name.slen);
p += attr-name.slen;

/* Attribute value. */
if (attr-value.slen) {
*p++ = '=';
*p++ = '"';
pj_memcpy(p, attr-value.ptr, attr-value.slen);
p += attr-value.slen;
*p++ = '"';
}

ifattr-value.slen == 0, i.e. empty attribute value, then it will print as xattributeA …  this then become an invalid xml string!

I think the checkif(attr-value.slen) is unnecessary because if it is 0,pj_memcpy(p, attr-value.ptr, attr-value.slen); is no-op so no harm here. But the result will become valid now, i.e.xattributeA =“" …

I thinkxml_print_node has some problem in processing empy attribute, e.g. x attributeA= “” … /x, here attributeA has an empty value So in code /* Attribute name. */ pj_memcpy(p, attr-name.ptr, attr-name.slen); p += attr-name.slen; /* Attribute value. */ if (attr-value.slen) { *p++ = '='; *p++ = '"'; pj_memcpy(p, attr-value.ptr, attr-value.slen); p += attr-value.slen; *p++ = '"'; } ifattr-value.slen == 0, i.e. empty attribute value, then it will print as xattributeA … this then become an invalid xml string! I think the checkif(attr-value.slen) is unnecessary because if it is 0,pj_memcpy(p, attr-value.ptr, attr-value.slen); is no-op so no harm here. But the result will become valid now, i.e.xattributeA =“" …