ReactOS 0.4.16-dev-736-g28b802b
|
#include "libxml.h"
#include <limits.h>
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/uri.h>
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
Go to the source code of this file.
Macros | |
#define | IN_LIBXML |
#define | MAX_URI_LENGTH 1024 * 1024 |
#define | IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x)) |
#define | IS_LOWALPHA(x) (((x) >= 'a') && ((x) <= 'z')) |
#define | IS_UPALPHA(x) (((x) >= 'A') && ((x) <= 'Z')) |
#define | IS_DIGIT(x) (((x) >= '0') && ((x) <= '9')) |
#define | IS_ALPHANUM(x) (IS_ALPHA(x) || IS_DIGIT(x)) |
#define | IS_MARK(x) |
#define | IS_UNWISE(p) |
#define | IS_RESERVED(x) |
#define | IS_UNRESERVED(x) (IS_ALPHANUM(x) || IS_MARK(x)) |
#define | NEXT(p) ((*p == '%')? p += 3 : p++) |
#define | STRNDUP(s, n) (char *) xmlStrndup((const xmlChar *)(s), (n)) |
#define | ISA_DIGIT(p) ((*(p) >= '0') && (*(p) <= '9')) |
#define | ISA_ALPHA(p) |
#define | ISA_HEXDIG(p) |
#define | ISA_SUB_DELIM(p) |
#define | ISA_GEN_DELIM(p) |
#define | ISA_RESERVED(p) (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p))) |
#define | ISA_UNRESERVED(p) |
#define | ISA_PCT_ENCODED(p) ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2))) |
#define | ISA_PCHAR(p) |
#define | NULLCHK(p) |
#define | IS_WINDOWS_PATH(p) |
#define IN_LIBXML |
uri.c: set of generic URI related routines
Reference: RFCs 3986, 2732 and 2373
See Copyright for the status of this software.
#define IS_ALPHA | ( | x | ) | (IS_LOWALPHA(x) || IS_UPALPHA(x)) |
xmlCanonicPath: @path: the resource locator in a filesystem notation
Constructs a canonic path from the specified path.
Returns a new canonic path, or a duplicate of the path parameter if the construction fails. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.
#define ISA_PCT_ENCODED | ( | p | ) | ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2))) |
#define ISA_RESERVED | ( | p | ) | (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p))) |
#define MAX_URI_LENGTH 1024 * 1024 |
MAX_URI_LENGTH:
The definition of the URI regexp in the above RFC has no size limit In practice they are usually relatively short except for the data URI scheme as defined in RFC 2397. Even for data URI the usual maximum size before hitting random practical limits is around 64 KB and 4KB is usually a maximum admitted limit for proper operations. The value below is more a security limit than anything else and really should never be hit by 'normal' operations Set to 1 MByte in 2012, this is only enforced on output
xmlBuildRelativeURI: @URI: the URI reference under consideration @base: the base value
Expresses the URI of the reference in terms relative to the base. Some examples of this operation include: base = "http://site1.com/docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif pic1.gif http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif
base = "docs/book1.html" URI input URI returned docs/pic1.gif pic1.gif docs/img/pic1.gif img/pic1.gif img/pic1.gif ../img/pic1.gif http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif
Note: if the URI reference is really weird or complicated, it may be worthwhile to first convert it into a "nice" one by calling xmlBuildURI (using 'base') before calling this routine, since this routine (for reasonable efficiency) assumes URI has already been through some validation.
Returns a new URI string (to be freed by the caller) or NULL in case error.
Definition at line 2173 of file uri.c.
xmlBuildURI: @URI: the URI instance found in the document @base: the base value
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
Returns a new URI string (to be freed by the caller) or NULL in case of error.
Definition at line 1892 of file uri.c.
Referenced by xmlCreateEntityParserCtxtInternal(), xmlSAX2EntityDecl(), xmlSAX2ResolveEntity(), xmlSAX2UnparsedEntityDecl(), xsltDocumentElem(), xsltDocumentFunction(), xsltLoadStylesheetPI(), xsltParseStylesheetImport(), and xsltParseStylesheetInclude().
Definition at line 2380 of file uri.c.
Referenced by xmlCtxtResetPush(), xmlNewInputFromFile(), xmlPathToURI(), and xmlSAX2ExternalSubset().
xmlCleanURI: @uri: pointer to an xmlURI
Make sure the xmlURI struct is free of content
Definition at line 1357 of file uri.c.
Referenced by xmlParse3986RelativeRef(), xmlParse3986URI(), and xmlParse3986URIReference().
xmlCreateURI:
Simply creates an empty xmlURI
Returns the new structure or NULL in case of error
Definition at line 1020 of file uri.c.
Referenced by xmlBuildRelativeURI(), xmlBuildURI(), xmlCanonicPath(), xmlParseURI(), xmlParseURIRaw(), xmlURIEscape(), and xsltCheckWrite().
xmlFreeURI: @uri: pointer to an xmlURI
Free up the xmlURI struct
Definition at line 1387 of file uri.c.
Referenced by xmlBuildURI(), xmlCanonicPath(), xmlParseEntityDecl(), xmlParseStartTag2(), xmlParseURI(), xmlParseURIRaw(), xmlPathToURI(), xmlURIEscape(), xsltCheckRead(), xsltCheckWrite(), xsltDocumentFunctionLoadDocument(), and xsltLoadStylesheetPI().
xmlNormalizeURIPath: @path: pointer to the path string
Applies the 5 normalization steps to a path string–that is, RFC 2396 Section 5.2, steps 6.c through 6.g.
Normalization occurs directly on the string, no new allocation is done
Returns 0 or an error code
Definition at line 1420 of file uri.c.
Referenced by xmlBuildURI().
xmlParse3986Authority: @uri: pointer to an URI structure @str: the string to analyze
Parse an authority part and fills in the appropriate fields of the @uri structure
authority = [ userinfo "@" ] host [ ":" port ]
Returns 0 or the error code
Definition at line 516 of file uri.c.
Referenced by xmlParse3986HierPart(), and xmlParse3986RelativeRef().
xmlParse3986DecOctet: @str: the string to analyze
dec-octet = DIGIT ; 0-9 / x31-39 DIGIT ; 10-99 / "1" 2DIGIT ; 100-199 / "2" x30-34 DIGIT ; 200-249 / "25" x30-35 ; 250-255
Skip a dec-octet.
Returns 0 if found and skipped, 1 otherwise
Definition at line 402 of file uri.c.
Referenced by xmlParse3986Host().
xmlParse3986Fragment: @uri: pointer to an URI structure @str: pointer to the string to analyze
Parse the query part of an URI
fragment = *( pchar / "/" / "?" ) NOTE: the strict syntax as defined by 3986 does not allow '[' and ']' in the fragment identifier but this is used very broadly for xpointer scheme selection, so we are allowing it here to not break for example all the DocBook processing chains.
Returns 0 or the error code
Definition at line 245 of file uri.c.
Referenced by xmlParse3986RelativeRef(), and xmlParse3986URI().
xmlParse3986HierPart: @uri: pointer to an URI structure @str: the string to analyze
Parse an hierarchical part and fills in the appropriate fields of the @uri structure
hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty
Returns 0 or the error code
Definition at line 760 of file uri.c.
Referenced by xmlParse3986URI().
xmlParse3986Host: @uri: pointer to an URI structure @str: the string to analyze
Parse an host part and fills in the appropriate fields of the @uri structure
host = IP-literal / IPv4address / reg-name IP-literal = "[" ( IPv6address / IPvFuture ) "]" IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet reg-name = *( unreserved / pct-encoded / sub-delims )
Returns 0 or the error code
Definition at line 440 of file uri.c.
Referenced by xmlParse3986Authority().
xmlParse3986PathAbEmpty: @uri: pointer to an URI structure @str: the string to analyze
Parse an path absolute or empty and fills in the appropriate fields of the @uri structure
path-abempty = *( "/" segment )
Returns 0 or the error code
Definition at line 587 of file uri.c.
Referenced by xmlParse3986HierPart(), and xmlParse3986RelativeRef().
xmlParse3986PathAbsolute: @uri: pointer to an URI structure @str: the string to analyze
Parse an path absolute and fills in the appropriate fields of the @uri structure
path-absolute = "/" [ segment-nz *( "/" segment ) ]
Returns 0 or the error code
Definition at line 627 of file uri.c.
Referenced by xmlParse3986HierPart(), and xmlParse3986RelativeRef().
xmlParse3986PathNoScheme: @uri: pointer to an URI structure @str: the string to analyze
Parse an path which is not a scheme and fills in the appropriate fields of the @uri structure
path-noscheme = segment-nz-nc *( "/" segment )
Returns 0 or the error code
Definition at line 715 of file uri.c.
Referenced by xmlParse3986RelativeRef().
xmlParse3986PathRootless: @uri: pointer to an URI structure @str: the string to analyze
Parse an path without root and fills in the appropriate fields of the @uri structure
path-rootless = segment-nz *( "/" segment )
Returns 0 or the error code
Definition at line 673 of file uri.c.
Referenced by xmlParse3986HierPart().
xmlParse3986Port: @uri: pointer to an URI structure @str: the string to analyze
Parse a port part and fills in the appropriate fields of the @uri structure
port = *DIGIT
Returns 0 or the error code
Definition at line 326 of file uri.c.
Referenced by xmlParse3986Authority().
xmlParse3986Query: @uri: pointer to an URI structure @str: pointer to the string to analyze
Parse the query part of an URI
query = *uric
Returns 0 or the error code
Definition at line 282 of file uri.c.
Referenced by xmlParse3986RelativeRef(), and xmlParse3986URI().
xmlParse3986RelativeRef: @uri: pointer to an URI structure @str: the string to analyze
Parse an URI string and fills in the appropriate fields of the @uri structure
relative-ref = relative-part [ "?" query ] [ "#" fragment ] relative-part = "//" authority path-abempty / path-absolute / path-noscheme / path-empty
Returns 0 or the error code
Definition at line 811 of file uri.c.
Referenced by xmlParse3986URIReference().
xmlParse3986Scheme: @uri: pointer to an URI structure @str: pointer to the string to analyze
Parse an URI scheme
ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
Returns 0 or the error code
Definition at line 209 of file uri.c.
Referenced by xmlParse3986URI().
xmlParse3986Segment: @str: the string to analyze @forbid: an optional forbidden character @empty: allow an empty segment
Parse a segment and fills in the appropriate fields of the @uri structure
segment = pchar segment-nz = 1*pchar segment-nz-nc = 1( unreserved / pct-encoded / sub-delims / "@" ) ; non-zero-length segment without any colon ":"
Returns 0 or the error code
Definition at line 558 of file uri.c.
Referenced by xmlParse3986PathAbEmpty(), xmlParse3986PathAbsolute(), xmlParse3986PathNoScheme(), and xmlParse3986PathRootless().
xmlParse3986URI: @uri: pointer to an URI structure @str: the string to analyze
Parse an URI string and fills in the appropriate fields of the @uri structure
scheme ":" hier-part [ "?" query ] [ "#" fragment ]
Returns 0 or the error code
Definition at line 865 of file uri.c.
Referenced by xmlParse3986URIReference().
xmlParse3986URIReference: @uri: pointer to an URI structure @str: the string to analyze
Parse an URI reference string and fills in the appropriate fields of the @uri structure
URI-reference = URI / relative-ref
Returns 0 or the error code
Definition at line 906 of file uri.c.
Referenced by xmlParseURI(), and xmlParseURIReference().
xmlParse3986Userinfo: @uri: pointer to an URI structure @str: the string to analyze
Parse an user information part and fills in the appropriate fields of the @uri structure
userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
Returns 0 or the error code
Definition at line 365 of file uri.c.
Referenced by xmlParse3986Authority().
xmlParseURI: @str: the URI string to analyze
Parse an URI based on RFC 3986
URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
Returns a newly built xmlURIPtr or NULL in case of error
Definition at line 940 of file uri.c.
Referenced by xmlCanonicPath(), xmlParseEntityDecl(), xmlParseStartTag2(), xmlPathToURI(), xsltCheckRead(), xsltCheckWrite(), xsltDocumentFunctionLoadDocument(), and xsltLoadStylesheetPI().
xmlParseURIRaw: @str: the URI string to analyze @raw: if 1 unescaping of URI pieces are disabled
Parse an URI but allows to keep intact the original fragments.
URI-reference = URI / relative-ref
Returns a newly built xmlURIPtr or NULL in case of error
xmlParseURIReference: @uri: pointer to an URI structure @str: the string to analyze
Parse an URI reference string based on RFC 3986 and fills in the appropriate fields of the @uri structure
URI-reference = URI / relative-ref
Returns 0 or the error code
Definition at line 970 of file uri.c.
Referenced by xmlBuildRelativeURI(), xmlBuildURI(), xmlParseURIRaw(), and xmlURIEscape().
xmlPathToURI: @path: the resource locator in a filesystem notation
Constructs an URI expressing the existing path
Returns a new URI, or a duplicate of the path parameter if the construction fails. The caller is responsible for freeing the memory occupied by the returned string. If there is insufficient memory available, or the argument is NULL, the function returns NULL.
Definition at line 2521 of file uri.c.
Referenced by xmlSAX2StartDocument().
xmlPrintURI: @stream: a FILE* for the output @uri: pointer to an xmlURI
Prints the URI in the stream @stream.
Definition at line 1340 of file uri.c.
xmlSaveUri: @uri: pointer to an xmlURI
Save the URI as an escaped string
Returns a new string (to be deallocated by caller)
Definition at line 1066 of file uri.c.
Referenced by xmlBuildURI(), xmlCanonicPath(), xmlPathToURI(), xmlPrintURI(), and xsltDocumentFunctionLoadDocument().
xmlSaveUriRealloc:
Function to handle properly a reallocation when saving an URI Also imposes some limit on the length of an URI string output
Definition at line 1039 of file uri.c.
Referenced by xmlSaveUri(), and xmlURIEscapeStr().
Definition at line 37 of file uri.c.
Referenced by xmlBuildURI(), xmlCreateURI(), xmlSaveUri(), xmlSaveUriRealloc(), xmlURIEscapeStr(), and xmlURIUnescapeString().
xmlURIEscape: @str: the string of the URI to escape
Escaping routine, does not do validity checks ! It will try to escape the chars needing this, but this is heuristic based it's impossible to be sure.
Returns an copy of the string, but escaped
25 May 2001 Uses xmlParseURI and xmlURIEscapeStr to try to escape correctly according to RFC2396.
Definition at line 1752 of file uri.c.
xmlURIEscapeStr: @str: string to escape @list: exception list string of chars not to escape
This routine escapes a string to hex, ignoring reserved characters (a-z) and the characters in the exception list.
Returns a new escaped string or NULL in case of error.
Definition at line 1679 of file uri.c.
Referenced by xmlCanonicPath(), xmlURIEscape(), and xsltDocumentElem().
xmlURIUnescapeString: @str: the string to unescape @len: the length in bytes to unescape (or <= 0 to indicate full string) @target: optional destination buffer
Unescaping routine, but does not check that the string is an URI. The output is a direct unsigned char translation of XX values (no encoding) Note that the length of the result can only be smaller or same size as the input string.
Returns a copy of the string, but unescaped, will return NULL only in case of error
Definition at line 1620 of file uri.c.
Referenced by xmlParse3986Fragment(), xmlParse3986Host(), xmlParse3986PathAbEmpty(), xmlParse3986PathAbsolute(), xmlParse3986PathNoScheme(), xmlParse3986PathRootless(), xmlParse3986Query(), and xmlParse3986Userinfo().