MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlBuildURISafe

Function xmlBuildURISafe

ThirdParty/libxml2/vtklibxml2/uri.c:2011–2343  ·  view source on GitHub ↗

* xmlBuildURISafe: * @URI: the URI instance found in the document * @base: the base value * @valPtr: pointer to result URI * * Computes he final URI of the reference done by checking that * the given URI is valid, and building the final URI using the * base URI. This is processed according to section 5.2 of the * RFC 2396 * * 5.2. Resolving Relative References to Absolute Form * * A

Source from the content-addressed store, hash-verified

2009 * code if URI or base are invalid.
2010 */
2011int
2012xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
2013 xmlChar *val = NULL;
2014 int ret, len, indx, cur, out;
2015 xmlURIPtr ref = NULL;
2016 xmlURIPtr bas = NULL;
2017 xmlURIPtr res = NULL;
2018
2019 if (valPtr == NULL)
2020 return(1);
2021 *valPtr = NULL;
2022
2023 if (URI == NULL)
2024 return(1);
2025
2026 if (base == NULL) {
2027 val = xmlStrdup(URI);
2028 if (val == NULL)
2029 return(-1);
2030 *valPtr = val;
2031 return(0);
2032 }
2033
2034 /*
2035 * 1) The URI reference is parsed into the potential four components and
2036 * fragment identifier, as described in Section 4.3.
2037 *
2038 * NOTE that a completely empty URI is treated by modern browsers
2039 * as a reference to "." rather than as a synonym for the current
2040 * URI. Should we do that here?
2041 */
2042 if (URI[0] != 0)
2043 ret = xmlParseURISafe((const char *) URI, &ref);
2044 else
2045 ret = 0;
2046 if (ret != 0)
2047 goto done;
2048 if ((ref != NULL) && (ref->scheme != NULL)) {
2049 /*
2050 * The URI is absolute don't modify.
2051 */
2052 val = xmlStrdup(URI);
2053 if (val == NULL)
2054 ret = -1;
2055 goto done;
2056 }
2057
2058 /*
2059 * If base has no scheme or authority, it is assumed to be a
2060 * filesystem path.
2061 */
2062 if (xmlStrstr(base, BAD_CAST "://") == NULL) {
2063 xmlFreeURI(ref);
2064 return(xmlResolvePath(URI, base, valPtr));
2065 }
2066
2067 ret = xmlParseURISafe((const char *) base, &bas);
2068 if (ret < 0)

Callers 7

xmlC14NFixupBaseAttrFunction · 0.85
xmlSAX2ResolveEntityFunction · 0.85
xmlSAX2EntityDeclFunction · 0.85
xmlNodeGetBaseSafeFunction · 0.85
xmlXIncludeAddNodeFunction · 0.85
xmlBuildURIFunction · 0.85

Calls 8

xmlStrdupFunction · 0.85
xmlParseURISafeFunction · 0.85
xmlStrstrFunction · 0.85
xmlFreeURIFunction · 0.85
xmlResolvePathFunction · 0.85
xmlSaveUriFunction · 0.85
xmlCreateURIFunction · 0.85
xmlNormalizeURIPathFunction · 0.85

Tested by

no test coverage detected