fix a case where a single-element root path (e.g. /printer) would not pass xmlNodeGetPath
This commit is contained in:
parent
2fc7f94154
commit
8d85732a7d
2 changed files with 20 additions and 24 deletions
|
@ -1,4 +1,6 @@
|
||||||
20-04-2008
|
20-04-2008
|
||||||
|
* fix a case where a single-element root path (e.g. "/printer") would not
|
||||||
|
pass xmlNodeGetPath
|
||||||
* fix a problem where attributes or elements starting with the same letter
|
* fix a problem where attributes or elements starting with the same letter
|
||||||
sequence could give a false negative result
|
sequence could give a false negative result
|
||||||
* Add a 'clear' attribute to the xmlErrorGet functions that indicates whether
|
* Add a 'clear' attribute to the xmlErrorGet functions that indicates whether
|
||||||
|
|
|
@ -44,9 +44,9 @@ typedef struct
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <stdlib.h> /* free, malloc */
|
||||||
#include <stdlib.h> /* free, malloc */
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -306,13 +306,10 @@ xmlNodeCopyName(const void *id, char *buf, size_t buflen)
|
||||||
assert(buf != 0);
|
assert(buf != 0);
|
||||||
assert(buflen > 0);
|
assert(buflen > 0);
|
||||||
|
|
||||||
slen = buflen-1;
|
slen = xid->name_len;
|
||||||
if (slen > xid->name_len)
|
if (slen >= buflen)
|
||||||
{
|
|
||||||
slen = xid->name_len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
slen = buflen-1;
|
||||||
xmlErrorSet(xid, 0, XML_TRUNCATE_RESULT);
|
xmlErrorSet(xid, 0, XML_TRUNCATE_RESULT);
|
||||||
}
|
}
|
||||||
memcpy(buf, xid->name, slen);
|
memcpy(buf, xid->name, slen);
|
||||||
|
@ -1292,13 +1289,13 @@ __xmlNodeGetPath(const char *start, size_t *len, char **name, size_t *plen)
|
||||||
|
|
||||||
assert(start != 0);
|
assert(start != 0);
|
||||||
assert(len != 0);
|
assert(len != 0);
|
||||||
|
assert(*len != 0);
|
||||||
assert(name != 0);
|
assert(name != 0);
|
||||||
assert(*name != 0);
|
assert(*name != 0);
|
||||||
assert(plen != 0);
|
assert(plen != 0);
|
||||||
assert(*plen != 0);
|
assert(*plen != 0);
|
||||||
|
|
||||||
if ((*len == 0) || (*plen == 0) || (*plen > *len))
|
if (*plen > *len) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
node = *name;
|
node = *name;
|
||||||
if (*node == '/') node++;
|
if (*node == '/') node++;
|
||||||
|
@ -1314,20 +1311,17 @@ __xmlNodeGetPath(const char *start, size_t *len, char **name, size_t *plen)
|
||||||
if (!path) plen = slen;
|
if (!path) plen = slen;
|
||||||
else plen = path++ - node;
|
else plen = path++ - node;
|
||||||
|
|
||||||
if (path)
|
num = 0;
|
||||||
|
ret = __xmlNodeGet(start, len, &node, &plen, &num);
|
||||||
|
if (ret && path)
|
||||||
{
|
{
|
||||||
num = 0;
|
plen = slen - (path - *name);
|
||||||
ret = __xmlNodeGet(start, len, &node, &plen, &num);
|
ret = __xmlNodeGetPath(ret, len, &path, &plen);
|
||||||
if (ret)
|
*name = path;
|
||||||
{
|
}
|
||||||
plen = slen - (path - *name);
|
else if (plen == 0)
|
||||||
ret = __xmlNodeGetPath(ret, len, &path, &plen);
|
{
|
||||||
*name = path;
|
*name = node;
|
||||||
}
|
|
||||||
else if (plen == 0)
|
|
||||||
{
|
|
||||||
*name = node;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,7 +1349,7 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
|
||||||
if (*rlen > *len)
|
if (*rlen > *len)
|
||||||
{
|
{
|
||||||
*rlen = 0;
|
*rlen = 0;
|
||||||
*name = start;
|
*name = (char *)start;
|
||||||
*len = XML_UNEXPECTED_EOF;
|
*len = XML_UNEXPECTED_EOF;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue