31#define URI_DISPLAY_NO_ABSOLUTE_URI 0x1
32#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH 0x2
34#define ALLOW_NULL_TERM_SCHEME 0x01
35#define ALLOW_NULL_TERM_USER_NAME 0x02
36#define ALLOW_NULL_TERM_PASSWORD 0x04
37#define ALLOW_BRACKETLESS_IP_LITERAL 0x08
38#define SKIP_IP_FUTURE_CHECK 0x10
39#define IGNORE_PORT_DELIMITER 0x20
41#define RAW_URI_FORCE_PORT_DISP 0x1
42#define RAW_URI_CONVERT_TO_DOS_PATH 0x2
44#define COMBINE_URI_FORCE_FLAG_USE 0x1
48static const IID IID_IUriObj = {0x4b364760,0x9f51,0x11df,{0x98,0x1c,0x08,0x00,0x20,0x0c,0x9a,0x66}};
215 {
URL_SCHEME_JAVASCRIPT, {
'j',
'a',
'v',
'a',
's',
'c',
'r',
'i',
'p',
't',0}},
216 {
URL_SCHEME_VBSCRIPT, {
'v',
'b',
's',
'c',
'r',
'i',
'p',
't',0}},
219 {
URL_SCHEME_MSSHELLROOTED, {
'm',
's',
'-',
's',
'h',
'e',
'l',
'l',
'-',
'r',
'o',
'o',
't',
'e',
'd',0}},
220 {
URL_SCHEME_MSSHELLIDLIST, {
'm',
's',
'-',
's',
'h',
'e',
'l',
'l',
'-',
'i',
'd',
'l',
'i',
's',
't',0}},
264 return ((
val >=
'a' &&
val <=
'z') || (
val >=
'A' &&
val <=
'Z'));
268 return (
val >=
'0' &&
val <=
'9');
276 return (
str[0] ==
'\\' &&
str[1] ==
'\\');
280 return (
val ==
'>' ||
val ==
'<' ||
val ==
'\"');
312 val ==
'_' ||
val ==
'~');
319 return (
val ==
'!' ||
val ==
'$' ||
val ==
'&' ||
320 val ==
'\'' ||
val ==
'(' ||
val ==
')' ||
321 val ==
'*' ||
val ==
'+' ||
val ==
',' ||
322 val ==
';' ||
val ==
'=');
327 return (
val ==
':' ||
val ==
'/' ||
val ==
'?' ||
328 val ==
'#' ||
val ==
'[' ||
val ==
']' ||
337 return (
val ==
'#' ||
val ==
'/' ||
val ==
'?' ||
338 val ==
'\0' || (acceptSlash &&
val ==
'\\'));
347 return ((
val >=
'a' &&
val <=
'f') ||
348 (
val >=
'A' &&
val <=
'F') ||
349 (
val >=
'0' &&
val <=
'9'));
358 return c ==
'/' ||
c ==
'\\';
388 return((
flags & Uri_CREATE_DECODE_EXTRA_INFO &&
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO) ||
389 (
flags & Uri_CREATE_CANONICALIZE &&
flags & Uri_CREATE_NO_CANONICALIZE) ||
390 (
flags & Uri_CREATE_CRACK_UNKNOWN_SCHEMES &&
flags & Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES) ||
391 (
flags & Uri_CREATE_PRE_PROCESS_HTML_URI &&
flags & Uri_CREATE_NO_PRE_PROCESS_HTML_URI) ||
392 (
flags & Uri_CREATE_IE_SETTINGS &&
flags & Uri_CREATE_NO_IE_SETTINGS));
399 if(!(*
flags & Uri_CREATE_NO_CANONICALIZE))
400 *
flags |= Uri_CREATE_CANONICALIZE;
401 if(!(*
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO))
402 *
flags |= Uri_CREATE_DECODE_EXTRA_INFO;
403 if(!(*
flags & Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES))
404 *
flags |= Uri_CREATE_CRACK_UNKNOWN_SCHEMES;
405 if(!(*
flags & Uri_CREATE_NO_PRE_PROCESS_HTML_URI))
406 *
flags |= Uri_CREATE_PRE_PROCESS_HTML_URI;
407 if(!(*
flags & Uri_CREATE_IE_SETTINGS))
408 *
flags |= Uri_CREATE_NO_IE_SETTINGS;
465 if(
val >=
'0' &&
val <=
'9')
467 else if(
val >=
'a' &&
val <=
'f')
468 return val -
'a' + 10;
469 else if(
val >=
'A' &&
val <=
'F')
470 return val -
'A' + 10;
522 const WCHAR *last_tld, *sec_last_tld, *
end, *
p;
538 sec_last_tld = last_tld;
553 if(last_tld-
host == 0) {
554 if(
end-(last_tld-1) < 3)
556 }
else if(last_tld-
host == 3) {
570 }
else if(last_tld-
host < 3)
579 }
else if(
end+1-last_tld > 3) {
584 *domain_start = (sec_last_tld+1)-
host;
585 }
else if(last_tld - (sec_last_tld+1) < 4) {
593 if(last_tld - (sec_last_tld+1) == 3) {
596 for (
p = sec_last_tld;
p >
host;
p--)
if (
p[-1] ==
'.')
break;
597 *domain_start =
p -
host;
599 (
host+host_len)-(
host+*domain_start)));
604 *domain_start = (sec_last_tld+1)-
host;
610 for (
p = sec_last_tld;
p >
host;
p--)
if (
p[-1] ==
'.')
break;
611 *domain_start =
p -
host;
618 *domain_start = (sec_last_tld+1)-
host;
622 (
host+host_len)-(
host+*domain_start)));
718 DWORD i, max_len, cur_len;
719 INT max_index, cur_index;
721 max_len = cur_len = 0;
722 max_index = cur_index = -1;
723 for(
i = 0;
i < 8; ++
i) {
725 BOOL is_end = (check_ipv4 ||
i == 7);
747 if(cur_len > 1 && cur_len > max_len) {
750 max_index = cur_index;
835 static const WCHAR formatW[] =
836 {
'%',
'u',
'.',
'%',
'u',
'.',
'%',
'u',
'.',
'%',
'u',0};
855 static const WCHAR formatW[] = {
'%',
'u',0};
876 for(
i = 0;
i < component.
len; ++
i) {
889 DWORD i, cur_component = 0;
894 if(
address->components[
i].str >
address->elision && !already_passed_elision) {
900 number[cur_component++] = 0;
902 already_passed_elision =
TRUE;
910 if(!already_passed_elision &&
address->elision) {
913 number[cur_component++] = 0;
919 if(cur_component != 6) {
920 ERR(
"(%p %p): Failed sanity check with %d\n",
address,
number, cur_component);
965 const WCHAR *c1, *c2, *c3;
969 if(*c1 <
'0' || *c1 >
'9')
979 if(*c2 <
'0' || *c2 >
'9')
986 if(*c3 <
'0' || *c3 >
'9')
990 if(*c1 >=
'2' && *c2 >=
'5' && *c3 >=
'5') {
1096 data->scheme_len = 0;
1106 **
ptr !=
'-' && **
ptr !=
'.')
1133 if(
data->scheme &&
data->scheme_len) {
1149 }
else if(
data->is_relative) {
1170 static const WCHAR fileW[] = {
'f',
'i',
'l',
'e',0};
1175 if(
flags & Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME) {
1185 TRACE(
"(%p %p %x): URI is implicitly a file path, but, the ALLOW_IMPLICIT_FILE_SCHEME flag wasn't set.\n",
1195 if(
flags & Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME) {
1201 }
else if (
flags & Uri_CREATE_ALLOW_RELATIVE) {
1205 TRACE(
"(%p %p %x): Malformed URI found. Unable to deduce scheme name.\n",
ptr,
data,
flags);
1210 if(!
data->is_relative)
1224 while(**
ptr !=
':' && **
ptr !=
'@') {
1252 while(**
ptr !=
'@') {
1309 data->username_len = 0;
1318 data->username_len = 0;
1320 data->password_len = 0;
1396 TRACE(
"(%p %p %x): URI didn't contain anything looking like an IPv4 address.\n",
1406 data->host_type = Uri_HOST_IPV4;
1426 TRACE(
"(%p %p %x): IPv4 address found. host=%s host_len=%d host_type=%d\n",
1453 const BOOL has_start_bracket = **
ptr ==
'[';
1456 BOOL inside_brackets = has_start_bracket;
1470 data->host_type = Uri_HOST_UNKNOWN;
1485 (is_res && **
ptr && **
ptr !=
'/')) {
1486 if(**
ptr ==
':' && !ignore_col) {
1488 if(!inside_brackets) {
1489 const WCHAR *tmp = (*ptr)++;
1509 }
else if(**
ptr ==
'%' && (known_scheme && !is_res)) {
1521 }
else if(**
ptr ==
']')
1522 inside_brackets =
FALSE;
1523 else if(**
ptr ==
'[')
1524 inside_brackets =
TRUE;
1529 if(has_start_bracket) {
1531 if(*(*
ptr-1) ==
']') {
1532 TRACE(
"(%p %p %x %x): Expected an IP literal inside of the host\n",
1545 if(
data->host_len == 0 || is_res)
1546 data->host_type = Uri_HOST_UNKNOWN;
1548 data->host_type = Uri_HOST_DNS;
1550 TRACE(
"(%p %p %x %x): Parsed reg-name. host=%s len=%d\n",
ptr,
data,
flags, extras,
1587 BOOL is_split = (**
ptr ==
':');
1588 BOOL is_elision = (is_split && !is_end && *(*
ptr+1) ==
':');
1593 if(is_split || is_end) {
1596 cur_len = *
ptr - cur_start;
1602 TRACE(
"(%p %p %x): h16 component to long.\n",
1612 if(!((*
ptr ==
start && is_elision) ||
1613 (is_end && (*
ptr-2) ==
ip.elision))) {
1615 TRACE(
"(%p %p %x): IPv6 component cannot have a length of 0.\n",
1623 if(
ip.h16_count >= 8) {
1625 TRACE(
"(%p %p %x): Not a IPv6 address, too many h16 components.\n",
1630 ip.components[
ip.h16_count].str = cur_start;
1631 ip.components[
ip.h16_count].len = cur_len;
1633 TRACE(
"(%p %p %x): Found h16 component %s, len=%d, h16_count=%d\n",
1648 TRACE(
"(%p %p %x): IPv6 address cannot have 2 elisions.\n",
1668 ip.ipv4 = cur_start;
1669 ip.ipv4_len = *
ptr - cur_start;
1671 TRACE(
"(%p %p %x): Found an attached IPv4 address %s len=%d.\n",
1684 if(
ip.components_size +
ip.elision_size != 16) {
1686 TRACE(
"(%p %p %x): Invalid IPv6 address, did not add up to 16 bytes.\n",
1691 if(
ip.elision_size == 2) {
1700 if(
ip.elision <
ip.components[0].str ||
1701 ip.elision >
ip.components[
ip.h16_count-1].str) {
1703 TRACE(
"(%p %p %x): Invalid IPv6 address. Detected elision of 2 bytes at the beginning or end of the address.\n",
1709 data->host_type = Uri_HOST_IPV6;
1713 TRACE(
"(%p %p %x): Found valid IPv6 literal %s len=%d\n",
1724 if(**
ptr !=
'v' && **
ptr !=
'V')
1754 data->host_type = Uri_HOST_UNKNOWN;
1769 }
else if(**
ptr ==
'[')
1817 TRACE(
"(%p %p %x %x): Malformed URI, Unknown host type.\n",
1846 static const WCHAR slash[] = {
'/',0};
1853 }
else if(!(
flags & Uri_CREATE_NO_CANONICALIZE)) {
1867 (
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
1873 }
else if(**
ptr ==
'\\') {
1877 if(
flags & Uri_CREATE_NO_CANONICALIZE) {
1926 if (is_mailto && (*
ptr)[0] ==
'/' && (*
ptr)[1] ==
'/')
1935 if(**
ptr ==
'%' && known_scheme) {
1943 (
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2001 !(
flags & Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES)) {
2006 if(**
ptr ==
'/' && *(*
ptr+1) ==
'/') {
2055 while(**
ptr && **
ptr !=
'#') {
2056 if(**
ptr ==
'%' && known_scheme &&
2057 !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
2095 if(**
ptr ==
'%' && known_scheme &&
2096 !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
2148 if(!
data->username) {
2149 uri->userinfo_start = -1;
2153 uri->userinfo_start =
uri->canon_len;
2175 if(!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2179 uri->canon_len += 3;
2196 if(!
data->password) {
2197 uri->userinfo_split = -1;
2201 if(
uri->userinfo_start == -1)
2203 uri->userinfo_start =
uri->canon_len;
2205 uri->userinfo_split =
uri->canon_len -
uri->userinfo_start;
2209 uri->canon_uri[
uri->canon_len] =
':';
2233 if(!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2237 uri->canon_len += 3;
2260 uri->userinfo_start =
uri->userinfo_split = -1;
2261 uri->userinfo_len = 0;
2263 if(!
data->username && !
data->password)
2273 uri->userinfo_len =
uri->canon_len -
uri->userinfo_start;
2275 TRACE(
"(%p %p %x %d): Canonicalized userinfo, userinfo_start=%d, userinfo=%s, userinfo_split=%d userinfo_len=%d.\n",
2277 uri->userinfo_split,
uri->userinfo_len);
2281 uri->canon_uri[
uri->canon_len] =
'@';
2309 {
'l',
'o',
'c',
'a',
'l',
'h',
'o',
's',
't',0};
2316 uri->host_start = -1;
2318 uri->host_type = Uri_HOST_UNKNOWN;
2325 uri->canon_uri[
uri->canon_len] =
'\\';
2326 uri->canon_uri[
uri->canon_len+1] =
'\\';
2328 uri->canon_len += 2;
2329 uri->authority_start =
uri->canon_len;
2332 uri->host_start =
uri->canon_len;
2335 if(*
ptr ==
'%' && known_scheme) {
2359 }
else if(*
ptr ==
'\\') {
2364 }
else if(!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
is_ascii(*
ptr) &&
2370 if(!(
flags & Uri_CREATE_NO_CANONICALIZE)) {
2376 uri->canon_len += 3;
2379 if(!(
flags & Uri_CREATE_NO_CANONICALIZE) && known_scheme)
2389 uri->host_len =
uri->canon_len -
uri->host_start;
2398 &(
uri->domain_offset));
2405 uri->host_start =
uri->canon_len;
2415 uri->canon_len +=
data->host_len;
2423 uri->host_len =
uri->canon_len -
uri->host_start;
2424 uri->host_type = Uri_HOST_IPV4;
2427 TRACE(
"%p %p %x %d): Canonicalized implicit IP address=%s len=%d\n",
2454 if(
data->has_implicit_ip)
2457 uri->host_start =
uri->canon_len;
2462 DWORD i, octetDigitCount = 0, octetCount = 0;
2465 for(
i = 0;
i <
data->host_len; ++
i) {
2466 if(
data->host[
i] ==
'0' && !octetHasDigit) {
2472 if(octetDigitCount == 2 ||
2473 i+1 ==
data->host_len ||
2474 data->host[
i+1] ==
'.') {
2478 TRACE(
"Adding zero\n");
2480 }
else if(
data->host[
i] ==
'.') {
2485 octetDigitCount = 0;
2486 octetHasDigit =
FALSE;
2494 octetHasDigit =
TRUE;
2501 for( ; octetCount < 3; ++octetCount) {
2503 uri->canon_uri[
uri->canon_len] =
'.';
2504 uri->canon_uri[
uri->canon_len+1] =
'0';
2507 uri->canon_len += 2;
2513 uri->canon_len +=
data->host_len;
2516 uri->host_len =
uri->canon_len -
uri->host_start;
2518 TRACE(
"(%p %p %x %d): Canonicalized IPv4 address, ip=%s len=%d\n",
2564 uri->host_start =
uri->canon_len;
2569 uri->canon_len +=
data->host_len;
2576 TRACE(
"(%p %p %x %d): Failed to compute numerical value for IPv6 address.\n",
2582 uri->canon_uri[
uri->canon_len] =
'[';
2589 computeOnly, elision_start, elision_len);
2591 for(
i = 0;
i < 8; ++
i) {
2592 BOOL in_elision = (elision_start > -1 &&
i >= elision_start &&
2593 i < elision_start+elision_len);
2594 BOOL do_ipv4 = (
i == 6 &&
data->ipv6_address.ipv4 && !in_elision &&
2595 data->ipv6_address.h16_count == 0);
2597 if(
i == elision_start) {
2599 uri->canon_uri[
uri->canon_len] =
':';
2600 uri->canon_uri[
uri->canon_len+1] =
':';
2602 uri->canon_len += 2;
2613 if(
i != 0 && !(elision_start > -1 &&
i == elision_start+elision_len)) {
2615 uri->canon_uri[
uri->canon_len] =
':';
2641 uri->canon_uri[
uri->canon_len] =
'0';
2644 static const WCHAR formatW[] = {
'%',
'x',0};
2659 uri->canon_uri[
uri->canon_len] =
']';
2663 uri->host_len =
uri->canon_len -
uri->host_start;
2666 TRACE(
"(%p %p %x %d): Canonicalized IPv6 address %s, len=%d\n",
data,
uri,
flags,
2675 uri->host_start = -1;
2677 uri->domain_offset = -1;
2680 switch(
data->host_type) {
2682 uri->host_type = Uri_HOST_DNS;
2688 uri->host_type = Uri_HOST_IPV4;
2697 uri->host_type = Uri_HOST_IPV6;
2699 case Uri_HOST_UNKNOWN:
2701 uri->host_start =
uri->canon_len;
2706 uri->canon_len +=
data->host_len;
2707 uri->host_len =
data->host_len;
2710 uri->host_type = Uri_HOST_UNKNOWN;
2713 FIXME(
"(%p %p %x %d): Canonicalization for host type %d not supported.\n",
data,
2727 uri->port_offset = -1;
2732 has_default_port =
TRUE;
2738 uri->has_port =
data->has_port || has_default_port;
2746 if(has_default_port &&
data->has_port &&
data->port_value == default_port) {
2748 if(
flags & Uri_CREATE_NO_CANONICALIZE) {
2749 uri->port_offset =
uri->canon_len-
uri->authority_start;
2751 uri->canon_uri[
uri->canon_len] =
':';
2758 uri->canon_len +=
data->port_len;
2767 uri->port = default_port;
2768 }
else if(
data->has_port) {
2769 uri->port_offset =
uri->canon_len-
uri->authority_start;
2771 uri->canon_uri[
uri->canon_len] =
':';
2774 if(
flags & Uri_CREATE_NO_CANONICALIZE &&
data->port) {
2778 uri->canon_len +=
data->port_len;
2787 }
else if(has_default_port)
2788 uri->port = default_port;
2795 uri->authority_start =
uri->canon_len;
2796 uri->authority_len = 0;
2807 if(
uri->host_start != -1 || (
data->is_relative && (
data->password ||
data->username)))
2808 uri->authority_len =
uri->canon_len -
uri->authority_start;
2810 uri->authority_start = -1;
2845 BOOL is_implicit_scheme,
WCHAR *ret_path) {
2858 if(is_file && !has_host) {
2862 ret_path[
len] =
'/';
2865 }
else if(*
ptr ==
'/') {
2866 if(!(
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2869 ret_path[
len] =
'/';
2879 ret_path[
len+1] =
':';
2886 if(!is_file && *
path && *
path !=
'/') {
2889 ret_path[
len] =
'/';
2896 if(*
ptr ==
'%' && !is_res) {
2904 if(force_encode || escape_pct) {
2909 do_default_action =
FALSE;
2920 }
else if(*
ptr ==
'/' && is_file && (
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2923 ret_path[
len] =
'\\';
2925 do_default_action =
FALSE;
2926 }
else if(*
ptr ==
'\\' && known_scheme) {
2927 if(!(is_file && (
flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
2930 ret_path[
len] =
'/';
2932 do_default_action =
FALSE;
2935 (!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) {
2936 if(!is_file || !(
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2941 do_default_action =
FALSE;
2945 if(do_default_action) {
2956 if(!(is_file && (
flags & Uri_CREATE_FILE_USE_DOS_PATH)) &&
2958 if(!(
flags & Uri_CREATE_NO_CANONICALIZE) && ret_path) {
2996 uri->path_start = -1;
3001 uri->path_start =
uri->canon_len;
3006 flags |= Uri_CREATE_FILE_USE_DOS_PATH;
3013 uri->path_len =
data->path_len;
3014 uri->canon_len +=
data->path_len;
3021 if(
data->scheme && *(
data->path) ==
'/' && *(
data->path+1) ==
'/') {
3024 uri->canon_uri[
uri->canon_len] =
'/';
3025 uri->canon_uri[
uri->canon_len+1] =
'.';
3028 uri->canon_len += 2;
3034 if(*
ptr ==
'%' && known_scheme) {
3045 }
else if(*
ptr ==
'/' && is_file && (
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
3047 uri->canon_uri[
uri->canon_len] =
'\\';
3049 do_default_action =
FALSE;
3050 }
else if(*
ptr ==
'\\') {
3051 if((
data->is_relative || is_mk || is_file) && !(
flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
3054 uri->canon_uri[
uri->canon_len] =
'/';
3056 do_default_action =
FALSE;
3058 }
else if(is_mk && *
ptr ==
':' &&
ptr + 1 <
data->path +
data->path_len && *(
ptr + 1) ==
':') {
3059 flags &= ~Uri_CREATE_FILE_USE_DOS_PATH;
3061 !(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
3062 if(!(is_file && (
flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
3065 uri->canon_len += 3;
3066 do_default_action =
FALSE;
3070 if(do_default_action) {
3077 if(is_mk && !computeOnly && !(
flags & Uri_CREATE_NO_CANONICALIZE)) {
3079 uri->canon_len -
uri->path_start);
3080 uri->canon_len =
uri->path_start + new_len;
3083 uri->path_len =
uri->canon_len -
uri->path_start;
3086 TRACE(
"(%p %p %x %d): Canonicalized opaque URI path %s len=%d\n",
data,
uri,
flags, computeOnly,
3098 if(!
data->is_opaque || (
data->is_relative && (
data->password ||
data->username))) {
3105 if((
data->is_relative && (
data->host ||
data->has_port)) ||
3113 uri->canon_uri[
pos] =
'/';
3114 uri->canon_uri[
pos+1] =
'/';
3116 uri->canon_len += 2;
3122 if(
data->is_relative && (
data->password ||
data->username)) {
3127 uri->path_start =
uri->canon_len;
3130 uri->canon_len +=
uri->path_len;
3131 if(!computeOnly && !
uri->path_len)
3132 uri->path_start = -1;
3136 uri->userinfo_start =
uri->userinfo_split = -1;
3137 uri->userinfo_len = 0;
3138 uri->host_start = -1;
3140 uri->host_type = Uri_HOST_UNKNOWN;
3142 uri->authority_start = -1;
3143 uri->authority_len = 0;
3144 uri->domain_offset = -1;
3145 uri->port_offset = -1;
3169 if(
uri->path_start > -1 && !computeOnly)
3173 uri->extension_offset = -1;
3193 uri->query_start = -1;
3198 uri->query_start =
uri->canon_len;
3203 if(known_scheme && !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3215 if(!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
3216 !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3219 uri->canon_len += 3;
3229 uri->query_len =
uri->canon_len -
uri->query_start;
3232 TRACE(
"(%p %p %x %d): Canonicalized query string %s len=%d\n",
data,
uri,
flags,
3242 if(!
data->fragment) {
3243 uri->fragment_start = -1;
3244 uri->fragment_len = 0;
3248 uri->fragment_start =
uri->canon_len;
3253 if(known_scheme && !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3265 if(!(
flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
3266 !(
flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3269 uri->canon_len += 3;
3279 uri->fragment_len =
uri->canon_len -
uri->fragment_start;
3290 uri->scheme_start = -1;
3291 uri->scheme_len = 0;
3297 if(!
data->is_relative) {
3298 FIXME(
"(%p %p %x): Unable to determine the scheme type of %s.\n",
data,
3307 for(
i = 0;
i <
data->scheme_len; ++
i) {
3312 uri->canon_uri[
i +
pos] =
':';
3320 uri->canon_len +=
data->scheme_len + 1;
3321 uri->scheme_len =
data->scheme_len;
3337 TRACE(
"(%p %x): Beginning to compute canonicalized length for URI %s\n",
data,
flags,
3341 ERR(
"(%p %x): Failed to compute URI scheme length.\n",
data,
flags);
3346 ERR(
"(%p %x): Failed to compute URI hierpart length.\n",
data,
flags);
3351 ERR(
"(%p %x): Failed to compute query string length.\n",
data,
flags);
3356 ERR(
"(%p %x): Failed to compute fragment length.\n",
data,
flags);
3360 TRACE(
"(%p %x): Finished computing canonicalized URI length. length=%d\n",
data,
flags,
uri.canon_len);
3362 return uri.canon_len;
3377 uri->canon_size =
uri->canon_len = 0;
3384 ERR(
"(%p %p %x): Could not compute the canonicalized length of %s.\n",
data,
uri,
flags,
3395 ERR(
"(%p %p %x): Unable to canonicalize the scheme of the URI.\n",
data,
uri,
flags);
3398 uri->scheme_type =
data->scheme_type;
3401 ERR(
"(%p %p %x): Unable to canonicalize the heirpart of the URI\n",
data,
uri,
flags);
3406 ERR(
"(%p %p %x): Unable to canonicalize query string of the URI.\n",
3412 ERR(
"(%p %p %x): Unable to canonicalize fragment of the URI.\n",
3420 if(
uri->canon_len <
uri->canon_size) {
3428 uri->canon_uri = tmp;
3429 uri->canon_size =
uri->canon_len;
3432 uri->canon_uri[
uri->canon_len] =
'\0';
3453 if(!(*component) &&
source) {
3462 (*component)[source_len] =
'\0';
3463 *component_len = source_len;
3466 *output = *component;
3467 *output_len = *component_len;
3490 if(prefix && *new_value != prefix) {
3500 (*component)[
pos++] = prefix;
3503 *component_len =
len+
pos;
3506 *
flags |= success_flag;
3549 const WCHAR *component;
3569 data->scheme_len == expected_len) {
3571 TRACE(
"(%p %p %x): Found valid scheme component %s len=%d.\n", builder,
data,
flags,
3574 TRACE(
"(%p %p %x): Invalid scheme component found %s.\n", builder,
data,
flags,
3576 return INET_E_INVALID_URL;
3606 data->username_len == expected_len)
3607 TRACE(
"(%p %p %x): Found valid username component %s len=%d.\n", builder,
data,
flags,
3610 TRACE(
"(%p %p %x): Invalid username component found %s.\n", builder,
data,
flags,
3612 return INET_E_INVALID_URL;
3641 data->password_len == expected_len)
3642 TRACE(
"(%p %p %x): Found valid password component %s len=%d.\n", builder,
data,
flags,
3645 TRACE(
"(%p %p %x): Invalid password component found %s.\n", builder,
data,
flags,
3647 return INET_E_INVALID_URL;
3688 TRACE(
"(%p %p %x): Found valid host name %s len=%d type=%d.\n", builder,
data,
flags,
3691 TRACE(
"(%p %p %x): Invalid host name found %s.\n", builder,
data,
flags,
3693 return INET_E_INVALID_URL;
3712 TRACE(
"(%p %p %x): Using %u as port for IUri.\n", builder,
data,
flags,
data->port_value);
3717 const WCHAR *component;
3746 if(!
valid || (check_len && expected_len !=
data->path_len)) {
3747 TRACE(
"(%p %p %x): Invalid path component %s.\n", builder,
data,
flags,
3749 return INET_E_INVALID_URL;
3752 TRACE(
"(%p %p %x): Valid path component %s len=%d.\n", builder,
data,
flags,
3763 if(builder->
query) {
3777 TRACE(
"(%p %p %x): Valid query component %s len=%d.\n", builder,
data,
flags,
3780 TRACE(
"(%p %p %x): Invalid query component %s.\n", builder,
data,
flags,
3782 return INET_E_INVALID_URL;