Lines Matching full:uri
2 * uri.c: set of generic URI related routines
18 #include <libxml/uri.h>
26 * The definition of the URI regexp in the above RFC has no size limit
28 * data URI scheme as defined in RFC 2397. Even for data URI the usual
40 static void xmlCleanURI(xmlURIPtr uri);
197 xmlIsUnreserved(xmlURIPtr uri, const char *cur) { in xmlIsUnreserved() argument
198 if (uri == NULL) in xmlIsUnreserved()
204 if (uri->cleanup & XML_URI_ALLOW_UNWISE) { in xmlIsUnreserved()
207 } else if (uri->cleanup & XML_URI_ALLOW_UCSCHAR) { in xmlIsUnreserved()
217 * @uri: pointer to an URI structure
220 * Parse an URI scheme
227 xmlParse3986Scheme(xmlURIPtr uri, const char **str) { in xmlParse3986Scheme() argument
236 if (uri != NULL) { in xmlParse3986Scheme()
237 if (uri->scheme != NULL) xmlFree(uri->scheme); in xmlParse3986Scheme()
238 uri->scheme = STRNDUP(*str, cur - *str); in xmlParse3986Scheme()
239 if (uri->scheme == NULL) in xmlParse3986Scheme()
248 * @uri: pointer to an URI structure
251 * Parse the query part of an URI
262 xmlParse3986Fragment(xmlURIPtr uri, const char **str) in xmlParse3986Fragment() argument
268 while ((ISA_PCHAR(uri, cur)) || (*cur == '/') || (*cur == '?') || in xmlParse3986Fragment()
271 if (uri != NULL) { in xmlParse3986Fragment()
272 if (uri->fragment != NULL) in xmlParse3986Fragment()
273 xmlFree(uri->fragment); in xmlParse3986Fragment()
274 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986Fragment()
275 uri->fragment = STRNDUP(*str, cur - *str); in xmlParse3986Fragment()
277 uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986Fragment()
278 if (uri->fragment == NULL) in xmlParse3986Fragment()
287 * @uri: pointer to an URI structure
290 * Parse the query part of an URI
297 xmlParse3986Query(xmlURIPtr uri, const char **str) in xmlParse3986Query() argument
303 while ((ISA_PCHAR(uri, cur)) || (*cur == '/') || (*cur == '?')) in xmlParse3986Query()
305 if (uri != NULL) { in xmlParse3986Query()
306 if (uri->query != NULL) in xmlParse3986Query()
307 xmlFree(uri->query); in xmlParse3986Query()
308 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986Query()
309 uri->query = STRNDUP(*str, cur - *str); in xmlParse3986Query()
311 uri->query = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986Query()
312 if (uri->query == NULL) in xmlParse3986Query()
318 if (uri->query_raw != NULL) in xmlParse3986Query()
319 xmlFree (uri->query_raw); in xmlParse3986Query()
320 uri->query_raw = STRNDUP (*str, cur - *str); in xmlParse3986Query()
321 if (uri->query_raw == NULL) in xmlParse3986Query()
330 * @uri: pointer to an URI structure
334 * of the @uri structure
341 xmlParse3986Port(xmlURIPtr uri, const char **str) in xmlParse3986Port() argument
359 if (uri != NULL) in xmlParse3986Port()
360 uri->port = port; in xmlParse3986Port()
369 * @uri: pointer to an URI structure
373 * of the @uri structure
380 xmlParse3986Userinfo(xmlURIPtr uri, const char **str) in xmlParse3986Userinfo() argument
385 while (ISA_UNRESERVED(uri, cur) || ISA_PCT_ENCODED(cur) || in xmlParse3986Userinfo()
389 if (uri != NULL) { in xmlParse3986Userinfo()
390 if (uri->user != NULL) xmlFree(uri->user); in xmlParse3986Userinfo()
391 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986Userinfo()
392 uri->user = STRNDUP(*str, cur - *str); in xmlParse3986Userinfo()
394 uri->user = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986Userinfo()
395 if (uri->user == NULL) in xmlParse3986Userinfo()
443 * @uri: pointer to an URI structure
447 * of the @uri structure
457 xmlParse3986Host(xmlURIPtr uri, const char **str) in xmlParse3986Host() argument
501 while (ISA_UNRESERVED(uri, cur) || in xmlParse3986Host()
505 if (uri != NULL) { in xmlParse3986Host()
506 if (uri->authority != NULL) xmlFree(uri->authority); in xmlParse3986Host()
507 uri->authority = NULL; in xmlParse3986Host()
508 if (uri->server != NULL) xmlFree(uri->server); in xmlParse3986Host()
510 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986Host()
511 uri->server = STRNDUP(host, cur - host); in xmlParse3986Host()
513 uri->server = xmlURIUnescapeString(host, cur - host, NULL); in xmlParse3986Host()
514 if (uri->server == NULL) in xmlParse3986Host()
517 uri->server = NULL; in xmlParse3986Host()
525 * @uri: pointer to an URI structure
529 * of the @uri structure
536 xmlParse3986Authority(xmlURIPtr uri, const char **str) in xmlParse3986Authority() argument
545 ret = xmlParse3986Userinfo(uri, &cur); in xmlParse3986Authority()
552 ret = xmlParse3986Host(uri, &cur); in xmlParse3986Authority()
556 ret = xmlParse3986Port(uri, &cur); in xmlParse3986Authority()
570 * of the @uri structure
580 xmlParse3986Segment(xmlURIPtr uri, const char **str, char forbid, int empty) in xmlParse3986Segment() argument
585 if (!ISA_PCHAR(uri, cur)) { in xmlParse3986Segment()
590 while (ISA_PCHAR(uri, cur) && (*cur != forbid)) in xmlParse3986Segment()
598 * @uri: pointer to an URI structure
602 * of the @uri structure
609 xmlParse3986PathAbEmpty(xmlURIPtr uri, const char **str) in xmlParse3986PathAbEmpty() argument
618 ret = xmlParse3986Segment(uri, &cur, 0, 1); in xmlParse3986PathAbEmpty()
621 if (uri != NULL) { in xmlParse3986PathAbEmpty()
622 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986PathAbEmpty()
624 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986PathAbEmpty()
625 uri->path = STRNDUP(*str, cur - *str); in xmlParse3986PathAbEmpty()
627 uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986PathAbEmpty()
628 if (uri->path == NULL) in xmlParse3986PathAbEmpty()
631 uri->path = NULL; in xmlParse3986PathAbEmpty()
640 * @uri: pointer to an URI structure
644 * of the @uri structure
651 xmlParse3986PathAbsolute(xmlURIPtr uri, const char **str) in xmlParse3986PathAbsolute() argument
661 ret = xmlParse3986Segment(uri, &cur, 0, 0); in xmlParse3986PathAbsolute()
665 ret = xmlParse3986Segment(uri, &cur, 0, 1); in xmlParse3986PathAbsolute()
669 if (uri != NULL) { in xmlParse3986PathAbsolute()
670 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986PathAbsolute()
672 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986PathAbsolute()
673 uri->path = STRNDUP(*str, cur - *str); in xmlParse3986PathAbsolute()
675 uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986PathAbsolute()
676 if (uri->path == NULL) in xmlParse3986PathAbsolute()
679 uri->path = NULL; in xmlParse3986PathAbsolute()
688 * @uri: pointer to an URI structure
692 * of the @uri structure
699 xmlParse3986PathRootless(xmlURIPtr uri, const char **str) in xmlParse3986PathRootless() argument
706 ret = xmlParse3986Segment(uri, &cur, 0, 0); in xmlParse3986PathRootless()
710 ret = xmlParse3986Segment(uri, &cur, 0, 1); in xmlParse3986PathRootless()
713 if (uri != NULL) { in xmlParse3986PathRootless()
714 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986PathRootless()
716 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986PathRootless()
717 uri->path = STRNDUP(*str, cur - *str); in xmlParse3986PathRootless()
719 uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986PathRootless()
720 if (uri->path == NULL) in xmlParse3986PathRootless()
723 uri->path = NULL; in xmlParse3986PathRootless()
732 * @uri: pointer to an URI structure
736 * of the @uri structure
743 xmlParse3986PathNoScheme(xmlURIPtr uri, const char **str) in xmlParse3986PathNoScheme() argument
750 ret = xmlParse3986Segment(uri, &cur, ':', 0); in xmlParse3986PathNoScheme()
754 ret = xmlParse3986Segment(uri, &cur, 0, 1); in xmlParse3986PathNoScheme()
757 if (uri != NULL) { in xmlParse3986PathNoScheme()
758 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986PathNoScheme()
760 if (uri->cleanup & XML_URI_NO_UNESCAPE) in xmlParse3986PathNoScheme()
761 uri->path = STRNDUP(*str, cur - *str); in xmlParse3986PathNoScheme()
763 uri->path = xmlURIUnescapeString(*str, cur - *str, NULL); in xmlParse3986PathNoScheme()
764 if (uri->path == NULL) in xmlParse3986PathNoScheme()
767 uri->path = NULL; in xmlParse3986PathNoScheme()
776 * @uri: pointer to an URI structure
780 * of the @uri structure
790 xmlParse3986HierPart(xmlURIPtr uri, const char **str) in xmlParse3986HierPart() argument
799 ret = xmlParse3986Authority(uri, &cur); in xmlParse3986HierPart()
802 * An empty server is marked with a special URI value. in xmlParse3986HierPart()
804 if ((uri->server == NULL) && (uri->port == PORT_EMPTY)) in xmlParse3986HierPart()
805 uri->port = PORT_EMPTY_SERVER; in xmlParse3986HierPart()
806 ret = xmlParse3986PathAbEmpty(uri, &cur); in xmlParse3986HierPart()
811 ret = xmlParse3986PathAbsolute(uri, &cur); in xmlParse3986HierPart()
813 } else if (ISA_PCHAR(uri, cur)) { in xmlParse3986HierPart()
814 ret = xmlParse3986PathRootless(uri, &cur); in xmlParse3986HierPart()
818 if (uri != NULL) { in xmlParse3986HierPart()
819 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986HierPart()
820 uri->path = NULL; in xmlParse3986HierPart()
829 * @uri: pointer to an URI structure
832 * Parse an URI string and fills in the appropriate fields
833 * of the @uri structure
844 xmlParse3986RelativeRef(xmlURIPtr uri, const char *str) { in xmlParse3986RelativeRef() argument
849 ret = xmlParse3986Authority(uri, &str); in xmlParse3986RelativeRef()
851 ret = xmlParse3986PathAbEmpty(uri, &str); in xmlParse3986RelativeRef()
854 ret = xmlParse3986PathAbsolute(uri, &str); in xmlParse3986RelativeRef()
856 } else if (ISA_PCHAR(uri, str)) { in xmlParse3986RelativeRef()
857 ret = xmlParse3986PathNoScheme(uri, &str); in xmlParse3986RelativeRef()
861 if (uri != NULL) { in xmlParse3986RelativeRef()
862 if (uri->path != NULL) xmlFree(uri->path); in xmlParse3986RelativeRef()
863 uri->path = NULL; in xmlParse3986RelativeRef()
869 ret = xmlParse3986Query(uri, &str); in xmlParse3986RelativeRef()
874 ret = xmlParse3986Fragment(uri, &str); in xmlParse3986RelativeRef()
878 xmlCleanURI(uri); in xmlParse3986RelativeRef()
887 * @uri: pointer to an URI structure
890 * Parse an URI string and fills in the appropriate fields
891 * of the @uri structure
898 xmlParse3986URI(xmlURIPtr uri, const char *str) { in xmlParse3986URI() argument
901 ret = xmlParse3986Scheme(uri, &str); in xmlParse3986URI()
907 ret = xmlParse3986HierPart(uri, &str); in xmlParse3986URI()
911 ret = xmlParse3986Query(uri, &str); in xmlParse3986URI()
916 ret = xmlParse3986Fragment(uri, &str); in xmlParse3986URI()
920 xmlCleanURI(uri); in xmlParse3986URI()
928 * @uri: pointer to an URI structure
931 * Parse an URI reference string and fills in the appropriate fields
932 * of the @uri structure
934 * URI-reference = URI / relative-ref
939 xmlParse3986URIReference(xmlURIPtr uri, const char *str) { in xmlParse3986URIReference() argument
944 xmlCleanURI(uri); in xmlParse3986URIReference()
950 ret = xmlParse3986URI(uri, str); in xmlParse3986URIReference()
954 xmlCleanURI(uri); in xmlParse3986URIReference()
955 ret = xmlParse3986RelativeRef(uri, str); in xmlParse3986URIReference()
957 xmlCleanURI(uri); in xmlParse3986URIReference()
966 * @str: the URI string to analyze
967 * @uriOut: optional pointer to parsed URI
969 * Parse an URI based on RFC 3986
971 * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
975 * Returns 0 on success, an error code (typically 1) if the URI is invalid
980 xmlURIPtr uri; in xmlParseURISafe() local
989 uri = xmlCreateURI(); in xmlParseURISafe()
990 if (uri == NULL) in xmlParseURISafe()
993 ret = xmlParse3986URIReference(uri, str); in xmlParseURISafe()
995 xmlFreeURI(uri); in xmlParseURISafe()
999 *uriOut = uri; in xmlParseURISafe()
1005 * @str: the URI string to analyze
1007 * Parse an URI based on RFC 3986
1009 * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
1015 xmlURIPtr uri; in xmlParseURI() local
1016 xmlParseURISafe(str, &uri); in xmlParseURI()
1017 return(uri); in xmlParseURI()
1022 * @uri: pointer to an URI structure
1025 * Parse an URI reference string based on RFC 3986 and fills in the
1026 * appropriate fields of the @uri structure
1028 * URI-reference = URI / relative-ref
1033 xmlParseURIReference(xmlURIPtr uri, const char *str) { in xmlParseURIReference() argument
1034 return(xmlParse3986URIReference(uri, str)); in xmlParseURIReference()
1039 * @str: the URI string to analyze
1040 * @raw: if 1 unescaping of URI pieces are disabled
1042 * Parse an URI but allows to keep intact the original fragments.
1044 * URI-reference = URI / relative-ref
1050 xmlURIPtr uri; in xmlParseURIRaw() local
1055 uri = xmlCreateURI(); in xmlParseURIRaw()
1056 if (uri != NULL) { in xmlParseURIRaw()
1058 uri->cleanup |= XML_URI_NO_UNESCAPE; in xmlParseURIRaw()
1060 ret = xmlParseURIReference(uri, str); in xmlParseURIRaw()
1062 xmlFreeURI(uri); in xmlParseURIRaw()
1066 return(uri); in xmlParseURIRaw()
1071 * Generic URI structure functions *
1097 * Function to handle properly a reallocation when saving an URI
1098 * Also imposes some limit on the length of an URI string output
1117 * @uri: pointer to an xmlURI
1119 * Save the URI as an escaped string
1124 xmlSaveUri(xmlURIPtr uri) { in xmlSaveUri() argument
1131 if (uri == NULL) return(NULL); in xmlSaveUri()
1140 if (uri->scheme != NULL) { in xmlSaveUri()
1141 p = uri->scheme; in xmlSaveUri()
1157 if (uri->opaque != NULL) { in xmlSaveUri()
1158 p = uri->opaque; in xmlSaveUri()
1176 if ((uri->server != NULL) || (uri->port != PORT_EMPTY)) { in xmlSaveUri()
1184 if (uri->user != NULL) { in xmlSaveUri()
1185 p = uri->user; in xmlSaveUri()
1213 if (uri->server != NULL) { in xmlSaveUri()
1214 p = uri->server; in xmlSaveUri()
1225 if (uri->port > 0) { in xmlSaveUri()
1231 len += snprintf((char *) &ret[len], max - len, ":%d", uri->port); in xmlSaveUri()
1233 } else if (uri->authority != NULL) { in xmlSaveUri()
1241 p = uri->authority; in xmlSaveUri()
1261 } else if (uri->scheme != NULL) { in xmlSaveUri()
1268 if (uri->path != NULL) { in xmlSaveUri()
1269 p = uri->path; in xmlSaveUri()
1274 if ((uri->scheme != NULL) && in xmlSaveUri()
1279 (xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) { in xmlSaveUri()
1309 if (uri->query_raw != NULL) { in xmlSaveUri()
1316 p = uri->query_raw; in xmlSaveUri()
1325 } else if (uri->query != NULL) { in xmlSaveUri()
1332 p = uri->query; in xmlSaveUri()
1351 if (uri->fragment != NULL) { in xmlSaveUri()
1358 p = uri->fragment; in xmlSaveUri()
1392 * @uri: pointer to an xmlURI
1394 * Prints the URI in the stream @stream.
1397 xmlPrintURI(FILE *stream, xmlURIPtr uri) { in xmlPrintURI() argument
1400 out = xmlSaveUri(uri); in xmlPrintURI()
1409 * @uri: pointer to an xmlURI
1414 xmlCleanURI(xmlURIPtr uri) { in xmlCleanURI() argument
1415 if (uri == NULL) return; in xmlCleanURI()
1417 if (uri->scheme != NULL) xmlFree(uri->scheme); in xmlCleanURI()
1418 uri->scheme = NULL; in xmlCleanURI()
1419 if (uri->server != NULL) xmlFree(uri->server); in xmlCleanURI()
1420 uri->server = NULL; in xmlCleanURI()
1421 if (uri->user != NULL) xmlFree(uri->user); in xmlCleanURI()
1422 uri->user = NULL; in xmlCleanURI()
1423 if (uri->path != NULL) xmlFree(uri->path); in xmlCleanURI()
1424 uri->path = NULL; in xmlCleanURI()
1425 if (uri->fragment != NULL) xmlFree(uri->fragment); in xmlCleanURI()
1426 uri->fragment = NULL; in xmlCleanURI()
1427 if (uri->opaque != NULL) xmlFree(uri->opaque); in xmlCleanURI()
1428 uri->opaque = NULL; in xmlCleanURI()
1429 if (uri->authority != NULL) xmlFree(uri->authority); in xmlCleanURI()
1430 uri->authority = NULL; in xmlCleanURI()
1431 if (uri->query != NULL) xmlFree(uri->query); in xmlCleanURI()
1432 uri->query = NULL; in xmlCleanURI()
1433 if (uri->query_raw != NULL) xmlFree(uri->query_raw); in xmlCleanURI()
1434 uri->query_raw = NULL; in xmlCleanURI()
1439 * @uri: pointer to an xmlURI
1444 xmlFreeURI(xmlURIPtr uri) { in xmlFreeURI() argument
1445 if (uri == NULL) return; in xmlFreeURI()
1447 if (uri->scheme != NULL) xmlFree(uri->scheme); in xmlFreeURI()
1448 if (uri->server != NULL) xmlFree(uri->server); in xmlFreeURI()
1449 if (uri->user != NULL) xmlFree(uri->user); in xmlFreeURI()
1450 if (uri->path != NULL) xmlFree(uri->path); in xmlFreeURI()
1451 if (uri->fragment != NULL) xmlFree(uri->fragment); in xmlFreeURI()
1452 if (uri->opaque != NULL) xmlFree(uri->opaque); in xmlFreeURI()
1453 if (uri->authority != NULL) xmlFree(uri->authority); in xmlFreeURI()
1454 if (uri->query != NULL) xmlFree(uri->query); in xmlFreeURI()
1455 if (uri->query_raw != NULL) xmlFree(uri->query_raw); in xmlFreeURI()
1456 xmlFree(uri); in xmlFreeURI()
1485 * Normalize a filesystem path or URI.
1609 * Unescaping routine, but does not check that the string is an URI. The
1735 * @str: the string of the URI to escape
1752 xmlURIPtr uri; in xmlURIEscape() local
1758 uri = xmlCreateURI(); in xmlURIEscape()
1759 if (uri != NULL) { in xmlURIEscape()
1763 uri->cleanup = XML_URI_ALLOW_UNWISE; in xmlURIEscape()
1764 ret2 = xmlParseURIReference(uri, (const char *)str); in xmlURIEscape()
1766 xmlFreeURI(uri); in xmlURIEscape()
1771 if (!uri) in xmlURIEscape()
1777 xmlFreeURI(uri); \ in xmlURIEscape()
1781 if (uri->scheme) { in xmlURIEscape()
1782 segment = xmlURIEscapeStr(BAD_CAST uri->scheme, BAD_CAST "+-."); in xmlURIEscape()
1789 if (uri->authority) { in xmlURIEscape()
1791 xmlURIEscapeStr(BAD_CAST uri->authority, BAD_CAST "/?;:@"); in xmlURIEscape()
1798 if (uri->user) { in xmlURIEscape()
1799 segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,"); in xmlURIEscape()
1807 if (uri->server) { in xmlURIEscape()
1808 segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@"); in xmlURIEscape()
1810 if (uri->user == NULL) in xmlURIEscape()
1816 if (uri->port > 0) { in xmlURIEscape()
1819 snprintf((char *) port, 11, "%d", uri->port); in xmlURIEscape()
1824 if (uri->path) { in xmlURIEscape()
1826 xmlURIEscapeStr(BAD_CAST uri->path, BAD_CAST ":@&=+$,/?;"); in xmlURIEscape()
1832 if (uri->query_raw) { in xmlURIEscape()
1834 ret = xmlStrcat(ret, BAD_CAST uri->query_raw); in xmlURIEscape()
1836 else if (uri->query) { in xmlURIEscape()
1838 xmlURIEscapeStr(BAD_CAST uri->query, BAD_CAST ";/?:@&=+,$"); in xmlURIEscape()
1845 if (uri->opaque) { in xmlURIEscape()
1846 segment = xmlURIEscapeStr(BAD_CAST uri->opaque, BAD_CAST ""); in xmlURIEscape()
1852 if (uri->fragment) { in xmlURIEscape()
1853 segment = xmlURIEscapeStr(BAD_CAST uri->fragment, BAD_CAST "#"); in xmlURIEscape()
1860 xmlFreeURI(uri); in xmlURIEscape()
1893 * @out: pointer to result URI
1898 * code if URI or base are invalid.
1924 * If a URI is resolved, we can assume it is a valid URI and not in xmlResolvePath()
1995 * @URI: the URI instance found in the document
1997 * @valPtr: pointer to result URI
1999 * Computes he final URI of the reference done by checking that
2000 * the given URI is valid, and building the final URI using the
2001 * base URI. This is processed according to section 5.2 of the
2009 * code if URI or base are invalid.
2012 xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) { in xmlBuildURISafe() argument
2023 if (URI == NULL) in xmlBuildURISafe()
2027 val = xmlStrdup(URI); in xmlBuildURISafe()
2035 * 1) The URI reference is parsed into the potential four components and in xmlBuildURISafe()
2038 * NOTE that a completely empty URI is treated by modern browsers in xmlBuildURISafe()
2040 * URI. Should we do that here? in xmlBuildURISafe()
2042 if (URI[0] != 0) in xmlBuildURISafe()
2043 ret = xmlParseURISafe((const char *) URI, &ref); in xmlBuildURISafe()
2050 * The URI is absolute don't modify. in xmlBuildURISafe()
2052 val = xmlStrdup(URI); in xmlBuildURISafe()
2064 return(xmlResolvePath(URI, base, valPtr)); in xmlBuildURISafe()
2096 * current document and we are done. Otherwise, the reference URI's in xmlBuildURISafe()
2098 * within the URI reference and not inherited from the base URI. in xmlBuildURISafe()
2167 * absolute URI and we are done. Otherwise, the reference URI's in xmlBuildURISafe()
2168 * scheme is inherited from the base URI's scheme component. in xmlBuildURISafe()
2200 * URI's authority is inherited from the base URI's authority in xmlBuildURISafe()
2201 * component, which will also be undefined if the URI scheme does not in xmlBuildURISafe()
2263 * URI's path. Although there are many ways to do this, we will in xmlBuildURISafe()
2279 * a) All but the last segment of the base URI's path component is in xmlBuildURISafe()
2326 * 7) The resulting URI components, including any inherited from the in xmlBuildURISafe()
2327 * base URI, are recombined to give the absolute form of the URI in xmlBuildURISafe()
2347 * @URI: the URI instance found in the document
2350 * Computes he final URI of the reference done by checking that
2351 * the given URI is valid, and building the final URI using the
2352 * base URI. This is processed according to section 5.2 of the
2357 * Returns a new URI string (to be freed by the caller) or NULL in case
2361 xmlBuildURI(const xmlChar *URI, const xmlChar *base) { in xmlBuildURI() argument
2364 xmlBuildURISafe(URI, base, &out); in xmlBuildURI()
2370 xmlURIPtr uri; in xmlParseUriOrPath() local
2377 uri = xmlCreateURI(); in xmlParseUriOrPath()
2378 if (uri == NULL) { in xmlParseUriOrPath()
2419 uri->server = xmlMemStrdup(server); in xmlParseUriOrPath()
2422 uri->server = (char *) xmlStrndup(BAD_CAST server, in xmlParseUriOrPath()
2426 if (uri->server == NULL) { in xmlParseUriOrPath()
2440 uri->scheme = xmlMemStrdup("file"); in xmlParseUriOrPath()
2441 if (uri->scheme == NULL) { in xmlParseUriOrPath()
2446 if (uri->server == NULL) in xmlParseUriOrPath()
2447 uri->port = PORT_EMPTY_SERVER; in xmlParseUriOrPath()
2453 uri->path = xmlMalloc(pathSize + prependSlash + 1); in xmlParseUriOrPath()
2454 if (uri->path == NULL) { in xmlParseUriOrPath()
2459 uri->path[0] = '/'; in xmlParseUriOrPath()
2460 memcpy(uri->path + 1, path, pathSize + 1); in xmlParseUriOrPath()
2462 memcpy(uri->path, path, pathSize + 1); in xmlParseUriOrPath()
2465 ret = xmlParseURIReference(uri, str); in xmlParseUriOrPath()
2469 xmlNormalizePath(uri->path, /* isFile */ 0); in xmlParseUriOrPath()
2473 if ((uri->path[0] == '/') && in xmlParseUriOrPath()
2474 (((uri->path[1] >= 'A') && (uri->path[1] <= 'Z')) || in xmlParseUriOrPath()
2475 ((uri->path[1] >= 'a') && (uri->path[1] <= 'z'))) && in xmlParseUriOrPath()
2476 (uri->path[2] == ':')) in xmlParseUriOrPath()
2477 *drive = uri->path[1]; in xmlParseUriOrPath()
2480 *out = uri; in xmlParseUriOrPath()
2481 uri = NULL; in xmlParseUriOrPath()
2485 xmlFreeURI(uri); in xmlParseUriOrPath()
2493 * @URI: the URI reference under consideration
2495 * @valPtr: pointer to result URI
2497 * Expresses the URI of the reference in terms relative to the
2501 * URI input URI returned
2506 * URI input URI returned
2515 * code if URI or base are invalid.
2518 xmlBuildRelativeURISafe(const xmlChar * URI, const xmlChar * base, in xmlBuildRelativeURISafe() argument
2536 if ((URI == NULL) || (*URI == 0)) in xmlBuildRelativeURISafe()
2539 ret = xmlParseUriOrPath((char *) URI, &ref, &refDrive); in xmlBuildRelativeURISafe()
2543 /* Return URI if URI is invalid */ in xmlBuildRelativeURISafe()
2545 val = xmlStrdup(URI); in xmlBuildRelativeURISafe()
2551 /* Return URI if base is empty */ in xmlBuildRelativeURISafe()
2559 /* Return URI if base is invalid */ in xmlBuildRelativeURISafe()
2565 * If the scheme / server on the URI differs from the base, in xmlBuildRelativeURISafe()
2566 * just return the URI in xmlBuildRelativeURISafe()
2597 * Return URI if URI and base aren't both absolute or relative. in xmlBuildRelativeURISafe()
2622 * In URI, "back up" to the last '/' encountered. This will be the in xmlBuildRelativeURISafe()
2623 * beginning of the "unique" suffix of URI in xmlBuildRelativeURISafe()
2641 * e.g: URI="foo/" base="foo/bar" -> "./" in xmlBuildRelativeURISafe()
2665 * length of the remainder of the URI, plus enough space in xmlBuildRelativeURISafe()
2683 * Finish up with the end of the URI in xmlBuildRelativeURISafe()
2736 * @URI: the URI reference under consideration
2741 * Returns a new URI string (to be freed by the caller) or NULL in case
2745 xmlBuildRelativeURI(const xmlChar * URI, const xmlChar * base) in xmlBuildRelativeURI() argument
2749 xmlBuildRelativeURISafe(URI, base, &val); in xmlBuildRelativeURI()
2780 /* Check if this is an "absolute uri" */ in xmlCanonicPath()
2801 * Constructs an URI expressing the existing path
2803 * Returns a new URI, or a duplicate of the path parameter if the