mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-19 14:50:07 +03:00
Johann Richard pointed out some XPointer problems for URN based URI
* uri.c: Johann Richard pointed out some XPointer problems for URN based URI references in XInclude. Modified the URI parsing and saving routines to allow correct parsing and saving of XPointers, especially when attached to "opaque" scheme accordingly to RFC 2396 Daniel
This commit is contained in:
parent
8db67d2704
commit
fdd27d2718
@ -1,3 +1,11 @@
|
||||
Thu Nov 28 12:53:22 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* uri.c: Johann Richard pointed out some XPointer problems for
|
||||
URN based URI references in XInclude. Modified the URI parsing
|
||||
and saving routines to allow correct parsing and saving of
|
||||
XPointers, especially when attached to "opaque" scheme accordingly
|
||||
to RFC 2396
|
||||
|
||||
Wed Nov 27 20:36:08 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* HTMLtree.c include/libxml/HTMLtree.h: applied the same kind
|
||||
|
78
uri.c
78
uri.c
@ -285,16 +285,6 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||
ret[len++] = lo + (lo > 9? 'A'-10 : '0');
|
||||
}
|
||||
}
|
||||
if (len >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSaveUri: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret[len++] = 0;
|
||||
} else {
|
||||
if (uri->server != NULL) {
|
||||
if (len + 3 >= max) {
|
||||
@ -488,7 +478,21 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uri->fragment != NULL) {
|
||||
}
|
||||
if (uri->fragment != NULL) {
|
||||
if (len + 3 >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret,
|
||||
(max + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSaveUri: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret[len++] = '#';
|
||||
p = uri->fragment;
|
||||
while (*p != 0) {
|
||||
if (len + 3 >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret,
|
||||
@ -499,41 +503,27 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret[len++] = '#';
|
||||
p = uri->fragment;
|
||||
while (*p != 0) {
|
||||
if (len + 3 >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret,
|
||||
(max + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSaveUri: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
||||
ret[len++] = *p++;
|
||||
else {
|
||||
int val = *(unsigned char *)p++;
|
||||
int hi = val / 0x10, lo = val % 0x10;
|
||||
ret[len++] = '%';
|
||||
ret[len++] = hi + (hi > 9? 'A'-10 : '0');
|
||||
ret[len++] = lo + (lo > 9? 'A'-10 : '0');
|
||||
}
|
||||
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
||||
ret[len++] = *p++;
|
||||
else {
|
||||
int val = *(unsigned char *)p++;
|
||||
int hi = val / 0x10, lo = val % 0x10;
|
||||
ret[len++] = '%';
|
||||
ret[len++] = hi + (hi > 9? 'A'-10 : '0');
|
||||
ret[len++] = lo + (lo > 9? 'A'-10 : '0');
|
||||
}
|
||||
}
|
||||
if (len >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSaveUri: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret[len++] = 0;
|
||||
}
|
||||
if (len >= max) {
|
||||
max *= 2;
|
||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||
if (ret == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"xmlSaveUri: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret[len++] = 0;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -1074,7 +1064,7 @@ xmlParseURIFragment(xmlURIPtr uri, const char **str)
|
||||
if (str == NULL)
|
||||
return (-1);
|
||||
|
||||
while (IS_URIC(cur) || ((uri->cleanup) && (IS_UNWISE(cur))))
|
||||
while (IS_URIC(cur) || IS_UNWISE(cur))
|
||||
NEXT(cur);
|
||||
if (uri != NULL) {
|
||||
if (uri->fragment != NULL)
|
||||
|
Loading…
x
Reference in New Issue
Block a user