ReactOS 0.4.15-dev-8119-g4fb2fdb
uri.c File Reference
#include <limits.h>
#include <wchar.h>
#include "urlmon_main.h"
#include "wine/debug.h"
#include "shlwapi.h"
#include "strsafe.h"
Include dependency graph for uri.c:

Go to the source code of this file.

Classes

struct  Uri
 
struct  UriBuilder
 
struct  h16
 
struct  ipv6_address
 
struct  parse_data
 
struct  persist_uri
 
struct  inproc_marshal_uri
 

Macros

#define NO_SHLWAPI_REG
 
#define URI_DISPLAY_NO_ABSOLUTE_URI   0x1
 
#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH   0x2
 
#define ALLOW_NULL_TERM_SCHEME   0x01
 
#define ALLOW_NULL_TERM_USER_NAME   0x02
 
#define ALLOW_NULL_TERM_PASSWORD   0x04
 
#define ALLOW_BRACKETLESS_IP_LITERAL   0x08
 
#define SKIP_IP_FUTURE_CHECK   0x10
 
#define IGNORE_PORT_DELIMITER   0x20
 
#define RAW_URI_FORCE_PORT_DISP   0x1
 
#define RAW_URI_CONVERT_TO_DOS_PATH   0x2
 
#define COMBINE_URI_FORCE_FLAG_USE   0x1
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (urlmon)
 
static Uriget_uri_obj (IUri *uri)
 
static BOOL is_alpha (WCHAR val)
 
static BOOL is_num (WCHAR val)
 
static BOOL is_drive_path (const WCHAR *str)
 
static BOOL is_unc_path (const WCHAR *str)
 
static BOOL is_forbidden_dos_path_char (WCHAR val)
 
static BOOL is_implicit_file_path (const WCHAR *str)
 
static BOOL check_hierarchical (const WCHAR **ptr)
 
static BOOL is_unreserved (WCHAR val)
 
static BOOL is_subdelim (WCHAR val)
 
static BOOL is_gendelim (WCHAR val)
 
static BOOL is_auth_delim (WCHAR val, BOOL acceptSlash)
 
static BOOL is_reserved (WCHAR val)
 
static BOOL is_hexdigit (WCHAR val)
 
static BOOL is_path_delim (URL_SCHEME scheme, WCHAR val)
 
static BOOL is_slash (WCHAR c)
 
static BOOL is_ascii (WCHAR c)
 
static BOOL is_default_port (URL_SCHEME scheme, DWORD port)
 
static BOOL is_hierarchical_scheme (URL_SCHEME type)
 
static BOOL has_invalid_flag_combination (DWORD flags)
 
static void apply_default_flags (DWORD *flags)
 
static BOOL is_hierarchical_uri (const WCHAR **ptr, const parse_data *data)
 
static void compute_ipv6_comps_size (ipv6_address *address)
 
static int hex_to_int (WCHAR val)
 
static WCHAR decode_pct_val (const WCHAR *ptr)
 
static void pct_encode_val (WCHAR val, WCHAR *dest)
 
void find_domain_name (const WCHAR *host, DWORD host_len, INT *domain_start)
 
static DWORD remove_dot_segments (WCHAR *path, DWORD path_len)
 
static INT find_file_extension (const WCHAR *path, DWORD path_len)
 
static void compute_elision_location (const ipv6_address *address, const USHORT values[8], INT *index, DWORD *count)
 
static BSTR pre_process_uri (LPCWSTR uri)
 
static UINT ipv4toui (const WCHAR *ip, DWORD len)
 
static DWORD ui2ipv4 (WCHAR *dest, UINT address)
 
static DWORD ui2str (WCHAR *dest, UINT value)
 
static USHORT h16tous (h16 component)
 
static BOOL ipv6_to_number (const ipv6_address *address, USHORT number[8])
 
static BOOL check_pct_encoded (const WCHAR **ptr)
 
static BOOL check_dec_octet (const WCHAR **ptr)
 
static BOOL check_implicit_ipv4 (const WCHAR **ptr, UINT *val)
 
static BOOL check_ipv4address (const WCHAR **ptr, BOOL strict)
 
static BOOL parse_scheme_name (const WCHAR **ptr, parse_data *data, DWORD extras)
 
static BOOL parse_scheme_type (parse_data *data)
 
static BOOL parse_scheme (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static BOOL parse_username (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static BOOL parse_password (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static void parse_userinfo (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_port (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_ipv4address (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_reg_name (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static BOOL parse_ipv6address (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_ipvfuture (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_ip_literal (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static BOOL parse_host (const WCHAR **ptr, parse_data *data, DWORD flags, DWORD extras)
 
static BOOL parse_authority (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_path_hierarchical (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_path_opaque (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_hierpart (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_query (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_fragment (const WCHAR **ptr, parse_data *data, DWORD flags)
 
static BOOL parse_uri (parse_data *data, DWORD flags)
 
static BOOL canonicalize_username (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_password (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_userinfo (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_reg_name (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_implicit_ipv4address (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_ipv4address (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_ipv6address (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_host (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_port (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_authority (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static DWORD canonicalize_path_hierarchical (const WCHAR *path, DWORD path_len, URL_SCHEME scheme_type, BOOL has_host, DWORD flags, BOOL is_implicit_scheme, WCHAR *ret_path)
 
static BOOL canonicalize_path_opaque (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_hierpart (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_query (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_fragment (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static BOOL canonicalize_scheme (const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
 
static int compute_canonicalized_length (const parse_data *data, DWORD flags)
 
static HRESULT canonicalize_uri (const parse_data *data, Uri *uri, DWORD flags)
 
static HRESULT get_builder_component (LPWSTR *component, DWORD *component_len, LPCWSTR source, DWORD source_len, LPCWSTR *output, DWORD *output_len)
 
static HRESULT set_builder_component (LPWSTR *component, DWORD *component_len, LPCWSTR new_value, WCHAR prefix, DWORD *flags, DWORD success_flag)
 
static void reset_builder (UriBuilder *builder)
 
static HRESULT validate_scheme_name (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_username (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_password (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_userinfo (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_host (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static void setup_port (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_path (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_query (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_fragment (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT validate_components (const UriBuilder *builder, parse_data *data, DWORD flags)
 
static HRESULT compare_file_paths (const Uri *a, const Uri *b, BOOL *ret)
 
static HRESULT compare_uris (const Uri *a, const Uri *b, BOOL *ret)
 
static void convert_to_dos_path (const WCHAR *path, DWORD path_len, WCHAR *output, DWORD *output_len)
 
static DWORD generate_raw_uri (const parse_data *data, BSTR uri, DWORD flags)
 
static HRESULT generate_uri (const UriBuilder *builder, const parse_data *data, Uri *uri, DWORD flags)
 
static Uriimpl_from_IUri (IUri *iface)
 
static void destroy_uri_obj (Uri *This)
 
static HRESULT WINAPI Uri_QueryInterface (IUri *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI Uri_AddRef (IUri *iface)
 
static ULONG WINAPI Uri_Release (IUri *iface)
 
static HRESULT WINAPI Uri_GetPropertyBSTR (IUri *iface, Uri_PROPERTY uriProp, BSTR *pbstrProperty, DWORD dwFlags)
 
static HRESULT WINAPI Uri_GetPropertyLength (IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
 
static HRESULT WINAPI Uri_GetPropertyDWORD (IUri *iface, Uri_PROPERTY uriProp, DWORD *pcchProperty, DWORD dwFlags)
 
static HRESULT WINAPI Uri_HasProperty (IUri *iface, Uri_PROPERTY uriProp, BOOL *pfHasProperty)
 
static HRESULT WINAPI Uri_GetAbsoluteUri (IUri *iface, BSTR *pstrAbsoluteUri)
 
static HRESULT WINAPI Uri_GetAuthority (IUri *iface, BSTR *pstrAuthority)
 
static HRESULT WINAPI Uri_GetDisplayUri (IUri *iface, BSTR *pstrDisplayUri)
 
static HRESULT WINAPI Uri_GetDomain (IUri *iface, BSTR *pstrDomain)
 
static HRESULT WINAPI Uri_GetExtension (IUri *iface, BSTR *pstrExtension)
 
static HRESULT WINAPI Uri_GetFragment (IUri *iface, BSTR *pstrFragment)
 
static HRESULT WINAPI Uri_GetHost (IUri *iface, BSTR *pstrHost)
 
static HRESULT WINAPI Uri_GetPassword (IUri *iface, BSTR *pstrPassword)
 
static HRESULT WINAPI Uri_GetPath (IUri *iface, BSTR *pstrPath)
 
static HRESULT WINAPI Uri_GetPathAndQuery (IUri *iface, BSTR *pstrPathAndQuery)
 
static HRESULT WINAPI Uri_GetQuery (IUri *iface, BSTR *pstrQuery)
 
static HRESULT WINAPI Uri_GetRawUri (IUri *iface, BSTR *pstrRawUri)
 
static HRESULT WINAPI Uri_GetSchemeName (IUri *iface, BSTR *pstrSchemeName)
 
static HRESULT WINAPI Uri_GetUserInfo (IUri *iface, BSTR *pstrUserInfo)
 
static HRESULT WINAPI Uri_GetUserName (IUri *iface, BSTR *pstrUserName)
 
static HRESULT WINAPI Uri_GetHostType (IUri *iface, DWORD *pdwHostType)
 
static HRESULT WINAPI Uri_GetPort (IUri *iface, DWORD *pdwPort)
 
static HRESULT WINAPI Uri_GetScheme (IUri *iface, DWORD *pdwScheme)
 
static HRESULT WINAPI Uri_GetZone (IUri *iface, DWORD *pdwZone)
 
static HRESULT WINAPI Uri_GetProperties (IUri *iface, DWORD *pdwProperties)
 
static HRESULT WINAPI Uri_IsEqual (IUri *iface, IUri *pUri, BOOL *pfEqual)
 
static Uriimpl_from_IUriBuilderFactory (IUriBuilderFactory *iface)
 
static HRESULT WINAPI UriBuilderFactory_QueryInterface (IUriBuilderFactory *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI UriBuilderFactory_AddRef (IUriBuilderFactory *iface)
 
static ULONG WINAPI UriBuilderFactory_Release (IUriBuilderFactory *iface)
 
static HRESULT WINAPI UriBuilderFactory_CreateIUriBuilder (IUriBuilderFactory *iface, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
 
static HRESULT WINAPI UriBuilderFactory_CreateInitializedIUriBuilder (IUriBuilderFactory *iface, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
 
static Uriimpl_from_IPersistStream (IPersistStream *iface)
 
static HRESULT WINAPI PersistStream_QueryInterface (IPersistStream *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI PersistStream_AddRef (IPersistStream *iface)
 
static ULONG WINAPI PersistStream_Release (IPersistStream *iface)
 
static HRESULT WINAPI PersistStream_GetClassID (IPersistStream *iface, CLSID *pClassID)
 
static HRESULT WINAPI PersistStream_IsDirty (IPersistStream *iface)
 
static HRESULT WINAPI PersistStream_Load (IPersistStream *iface, IStream *pStm)
 
static BYTEpersist_stream_add_strprop (Uri *This, BYTE *p, DWORD type, DWORD len, WCHAR *data)
 
static void persist_stream_save (Uri *This, IStream *pStm, BOOL marshal, struct persist_uri *data)
 
static HRESULT WINAPI PersistStream_Save (IPersistStream *iface, IStream *pStm, BOOL fClearDirty)
 
static HRESULT WINAPI PersistStream_GetSizeMax (IPersistStream *iface, ULARGE_INTEGER *pcbSize)
 
static Uriimpl_from_IMarshal (IMarshal *iface)
 
static HRESULT WINAPI Marshal_QueryInterface (IMarshal *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI Marshal_AddRef (IMarshal *iface)
 
static ULONG WINAPI Marshal_Release (IMarshal *iface)
 
static HRESULT WINAPI Marshal_GetUnmarshalClass (IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, CLSID *pCid)
 
static HRESULT WINAPI Marshal_GetMarshalSizeMax (IMarshal *iface, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags, DWORD *pSize)
 
static HRESULT WINAPI Marshal_MarshalInterface (IMarshal *iface, IStream *pStm, REFIID riid, void *pv, DWORD dwDestContext, void *pvDestContext, DWORD mshlflags)
 
static HRESULT WINAPI Marshal_UnmarshalInterface (IMarshal *iface, IStream *pStm, REFIID riid, void **ppv)
 
static HRESULT WINAPI Marshal_ReleaseMarshalData (IMarshal *iface, IStream *pStm)
 
static HRESULT WINAPI Marshal_DisconnectObject (IMarshal *iface, DWORD dwReserved)
 
HRESULT Uri_Construct (IUnknown *pUnkOuter, LPVOID *ppobj)
 
HRESULT WINAPI CreateUri (LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
 
HRESULT WINAPI CreateUriWithFragment (LPCWSTR pwzURI, LPCWSTR pwzFragment, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
 
static HRESULT build_uri (const UriBuilder *builder, IUri **uri, DWORD create_flags, DWORD use_orig_flags, DWORD encoding_mask)
 
static UriBuilderimpl_from_IUriBuilder (IUriBuilder *iface)
 
static HRESULT WINAPI UriBuilder_QueryInterface (IUriBuilder *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI UriBuilder_AddRef (IUriBuilder *iface)
 
static ULONG WINAPI UriBuilder_Release (IUriBuilder *iface)
 
static HRESULT WINAPI UriBuilder_CreateUriSimple (IUriBuilder *iface, DWORD dwAllowEncodingPropertyMask, DWORD_PTR dwReserved, IUri **ppIUri)
 
static HRESULT WINAPI UriBuilder_CreateUri (IUriBuilder *iface, DWORD dwCreateFlags, DWORD dwAllowEncodingPropertyMask, DWORD_PTR dwReserved, IUri **ppIUri)
 
static HRESULT WINAPI UriBuilder_CreateUriWithFlags (IUriBuilder *iface, DWORD dwCreateFlags, DWORD dwUriBuilderFlags, DWORD dwAllowEncodingPropertyMask, DWORD_PTR dwReserved, IUri **ppIUri)
 
static HRESULT WINAPI UriBuilder_GetIUri (IUriBuilder *iface, IUri **ppIUri)
 
static HRESULT WINAPI UriBuilder_SetIUri (IUriBuilder *iface, IUri *pIUri)
 
static HRESULT WINAPI UriBuilder_GetFragment (IUriBuilder *iface, DWORD *pcchFragment, LPCWSTR *ppwzFragment)
 
static HRESULT WINAPI UriBuilder_GetHost (IUriBuilder *iface, DWORD *pcchHost, LPCWSTR *ppwzHost)
 
static HRESULT WINAPI UriBuilder_GetPassword (IUriBuilder *iface, DWORD *pcchPassword, LPCWSTR *ppwzPassword)
 
static HRESULT WINAPI UriBuilder_GetPath (IUriBuilder *iface, DWORD *pcchPath, LPCWSTR *ppwzPath)
 
static HRESULT WINAPI UriBuilder_GetPort (IUriBuilder *iface, BOOL *pfHasPort, DWORD *pdwPort)
 
static HRESULT WINAPI UriBuilder_GetQuery (IUriBuilder *iface, DWORD *pcchQuery, LPCWSTR *ppwzQuery)
 
static HRESULT WINAPI UriBuilder_GetSchemeName (IUriBuilder *iface, DWORD *pcchSchemeName, LPCWSTR *ppwzSchemeName)
 
static HRESULT WINAPI UriBuilder_GetUserName (IUriBuilder *iface, DWORD *pcchUserName, LPCWSTR *ppwzUserName)
 
static HRESULT WINAPI UriBuilder_SetFragment (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetHost (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetPassword (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetPath (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetPort (IUriBuilder *iface, BOOL fHasPort, DWORD dwNewValue)
 
static HRESULT WINAPI UriBuilder_SetQuery (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetSchemeName (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_SetUserName (IUriBuilder *iface, LPCWSTR pwzNewValue)
 
static HRESULT WINAPI UriBuilder_RemoveProperties (IUriBuilder *iface, DWORD dwPropertyMask)
 
static HRESULT WINAPI UriBuilder_HasBeenModified (IUriBuilder *iface, BOOL *pfModified)
 
HRESULT WINAPI CreateIUriBuilder (IUri *pIUri, DWORD dwFlags, DWORD_PTR dwReserved, IUriBuilder **ppIUriBuilder)
 
static HRESULT merge_paths (parse_data *data, const WCHAR *base, DWORD base_len, const WCHAR *relative, DWORD relative_len, WCHAR **result, DWORD *result_len, DWORD flags)
 
static HRESULT combine_uri (Uri *base, Uri *relative, DWORD flags, IUri **result, DWORD extras)
 
HRESULT WINAPI CoInternetCombineIUri (IUri *pBaseUri, IUri *pRelativeUri, DWORD dwCombineFlags, IUri **ppCombinedUri, DWORD_PTR dwReserved)
 
HRESULT WINAPI CoInternetCombineUrlEx (IUri *pBaseUri, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, IUri **ppCombinedUri, DWORD_PTR dwReserved)
 
static HRESULT parse_canonicalize (const Uri *uri, DWORD flags, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_friendly (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_rootdocument (const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_document (const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_path_from_url (const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_url_from_path (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_schema (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_site (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_domain (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
static HRESULT parse_anchor (IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
 
HRESULT WINAPI CoInternetParseIUri (IUri *pIUri, PARSEACTION ParseAction, DWORD dwFlags, LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD_PTR dwReserved)
 

Variables

static const IID IID_IUriObj = {0x4b364760,0x9f51,0x11df,{0x98,0x1c,0x08,0x00,0x20,0x0c,0x9a,0x66}}
 
static const CHAR hexDigits [] = "0123456789ABCDEF"
 
struct {
   URL_SCHEME   scheme
 
   WCHAR   scheme_name [16]
 
recognized_schemes []
 
struct {
   URL_SCHEME   scheme
 
   USHORT   port
 
default_ports []
 
struct {
   WCHAR   tld_name [4]
 
recognized_tlds []
 
static const IUriVtbl UriVtbl
 
static const IUriBuilderFactoryVtbl UriBuilderFactoryVtbl
 
static const IPersistStreamVtbl PersistStreamVtbl
 
static const IMarshalVtbl MarshalVtbl
 
static const IUriBuilderVtbl UriBuilderVtbl
 

Macro Definition Documentation

◆ ALLOW_BRACKETLESS_IP_LITERAL

#define ALLOW_BRACKETLESS_IP_LITERAL   0x08

Definition at line 37 of file uri.c.

◆ ALLOW_NULL_TERM_PASSWORD

#define ALLOW_NULL_TERM_PASSWORD   0x04

Definition at line 36 of file uri.c.

◆ ALLOW_NULL_TERM_SCHEME

#define ALLOW_NULL_TERM_SCHEME   0x01

Definition at line 34 of file uri.c.

◆ ALLOW_NULL_TERM_USER_NAME

#define ALLOW_NULL_TERM_USER_NAME   0x02

Definition at line 35 of file uri.c.

◆ COMBINE_URI_FORCE_FLAG_USE

#define COMBINE_URI_FORCE_FLAG_USE   0x1

Definition at line 44 of file uri.c.

◆ IGNORE_PORT_DELIMITER

#define IGNORE_PORT_DELIMITER   0x20

Definition at line 39 of file uri.c.

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 26 of file uri.c.

◆ RAW_URI_CONVERT_TO_DOS_PATH

#define RAW_URI_CONVERT_TO_DOS_PATH   0x2

Definition at line 42 of file uri.c.

◆ RAW_URI_FORCE_PORT_DISP

#define RAW_URI_FORCE_PORT_DISP   0x1

Definition at line 41 of file uri.c.

◆ SKIP_IP_FUTURE_CHECK

#define SKIP_IP_FUTURE_CHECK   0x10

Definition at line 38 of file uri.c.

◆ URI_DISPLAY_NO_ABSOLUTE_URI

#define URI_DISPLAY_NO_ABSOLUTE_URI   0x1

Definition at line 31 of file uri.c.

◆ URI_DISPLAY_NO_DEFAULT_PORT_AUTH

#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH   0x2

Definition at line 32 of file uri.c.

Function Documentation

◆ apply_default_flags()

static void apply_default_flags ( DWORD flags)
static

Definition at line 398 of file uri.c.

398 {
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;
409}
GLbitfield flags
Definition: glext.h:7161

Referenced by build_uri(), combine_uri(), and CreateUri().

◆ build_uri()

static HRESULT build_uri ( const UriBuilder builder,
IUri **  uri,
DWORD  create_flags,
DWORD  use_orig_flags,
DWORD  encoding_mask 
)
static

Definition at line 5850 of file uri.c.

5852{
5853 HRESULT hr;
5855 Uri *ret;
5856
5857 if(!uri)
5858 return E_POINTER;
5859
5860 if(encoding_mask && (!builder->uri || builder->modified_props)) {
5861 *uri = NULL;
5862 return E_NOTIMPL;
5863 }
5864
5865 /* Decide what flags should be used when creating the Uri. */
5866 if((use_orig_flags & UriBuilder_USE_ORIGINAL_FLAGS) && builder->uri)
5867 create_flags = builder->uri->create_flags;
5868 else {
5870 *uri = NULL;
5871 return E_INVALIDARG;
5872 }
5873
5874 /* Set the default flags if they don't cause a conflict. */
5876 }
5877
5878 /* Return the base IUri if no changes have been made and the create_flags match. */
5879 if(builder->uri && !builder->modified_props && builder->uri->create_flags == create_flags) {
5880 *uri = &builder->uri->IUri_iface;
5881 IUri_AddRef(*uri);
5882 return S_OK;
5883 }
5884
5886 if(FAILED(hr)) {
5887 *uri = NULL;
5888 return hr;
5889 }
5890
5891 hr = Uri_Construct(NULL, (void**)&ret);
5892 if(FAILED(hr)) {
5893 *uri = NULL;
5894 return hr;
5895 }
5896
5897 hr = generate_uri(builder, &data, ret, create_flags);
5898 if(FAILED(hr)) {
5899 IUri_Release(&ret->IUri_iface);
5900 *uri = NULL;
5901 return hr;
5902 }
5903
5904 *uri = &ret->IUri_iface;
5905 return S_OK;
5906}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
static BOOL has_invalid_flag_combination(DWORD flags)
Definition: uri.c:387
static HRESULT generate_uri(const UriBuilder *builder, const parse_data *data, Uri *uri, DWORD flags)
Definition: uri.c:4186
HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
Definition: uri.c:5656
static void apply_default_flags(DWORD *flags)
Definition: uri.c:398
static HRESULT validate_components(const UriBuilder *builder, parse_data *data, DWORD flags)
Definition: uri.c:3820
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
const char * uri
Definition: sec_mgr.c:1588
DWORD create_flags
Definition: sec_mgr.c:1589
HRESULT hr
Definition: shlfolder.c:183
DWORD modified_props
Definition: uri.c:104
Uri * uri
Definition: uri.c:103
Definition: uri.c:50
IUri IUri_iface
Definition: uri.c:51
DWORD create_flags
Definition: uri.c:65
int ret
#define E_POINTER
Definition: winerror.h:2365

Referenced by UriBuilder_CreateUri(), UriBuilder_CreateUriSimple(), and UriBuilder_CreateUriWithFlags().

◆ canonicalize_authority()

static BOOL canonicalize_authority ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2794 of file uri.c.

2794 {
2795 uri->authority_start = uri->canon_len;
2796 uri->authority_len = 0;
2797
2798 if(!canonicalize_userinfo(data, uri, flags, computeOnly))
2799 return FALSE;
2800
2801 if(!canonicalize_host(data, uri, flags, computeOnly))
2802 return FALSE;
2803
2804 if(!canonicalize_port(data, uri, flags, computeOnly))
2805 return FALSE;
2806
2807 if(uri->host_start != -1 || (data->is_relative && (data->password || data->username)))
2808 uri->authority_len = uri->canon_len - uri->authority_start;
2809 else
2810 uri->authority_start = -1;
2811
2812 return TRUE;
2813}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL canonicalize_userinfo(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2259
static BOOL canonicalize_host(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2674
static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2722

Referenced by canonicalize_hierpart().

◆ canonicalize_fragment()

static BOOL canonicalize_fragment ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 3238 of file uri.c.

3238 {
3239 const WCHAR *ptr, *end;
3240 const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
3241
3242 if(!data->fragment) {
3243 uri->fragment_start = -1;
3244 uri->fragment_len = 0;
3245 return TRUE;
3246 }
3247
3248 uri->fragment_start = uri->canon_len;
3249
3250 end = data->fragment + data->fragment_len;
3251 for(ptr = data->fragment; ptr < end; ++ptr) {
3252 if(*ptr == '%') {
3253 if(known_scheme && !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3255 if(is_unreserved(val)) {
3256 if(!computeOnly)
3257 uri->canon_uri[uri->canon_len] = val;
3258 ++uri->canon_len;
3259
3260 ptr += 2;
3261 continue;
3262 }
3263 }
3264 } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) {
3265 if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
3266 !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3267 if(!computeOnly)
3268 pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
3269 uri->canon_len += 3;
3270 continue;
3271 }
3272 }
3273
3274 if(!computeOnly)
3275 uri->canon_uri[uri->canon_len] = *ptr;
3276 ++uri->canon_len;
3277 }
3278
3279 uri->fragment_len = uri->canon_len - uri->fragment_start;
3280
3281 if(!computeOnly)
3282 TRACE("(%p %p %x %d): Canonicalized fragment %s len=%d\n", data, uri, flags,
3283 computeOnly, debugstr_wn(uri->canon_uri+uri->fragment_start, uri->fragment_len),
3284 uri->fragment_len);
3285 return TRUE;
3286}
static BOOL is_reserved(WCHAR val)
Definition: uri.c:342
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:483
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:310
static BOOL is_ascii(WCHAR c)
Definition: uri.c:361
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:504
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLuint end
Definition: gl.h:1545
GLuint GLfloat * val
Definition: glext.h:7180
#define debugstr_wn
Definition: kernel32.h:33
static PVOID ptr
Definition: dispmode.c:27
@ URL_SCHEME_UNKNOWN
Definition: shlwapi.h:1146
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by canonicalize_uri(), and compute_canonicalized_length().

◆ canonicalize_hierpart()

static BOOL canonicalize_hierpart ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 3097 of file uri.c.

3097 {
3098 if(!data->is_opaque || (data->is_relative && (data->password || data->username))) {
3099 /* "//" is only added for non-wildcard scheme types.
3100 *
3101 * A "//" is only added to a relative URI if it has a
3102 * host or port component (this only happens if a IUriBuilder
3103 * is generating an IUri).
3104 */
3105 if((data->is_relative && (data->host || data->has_port)) ||
3106 (!data->is_relative && data->scheme_type != URL_SCHEME_WILDCARD)) {
3107 if(data->scheme_type == URL_SCHEME_WILDCARD)
3108 FIXME("Here\n");
3109
3110 if(!computeOnly) {
3111 INT pos = uri->canon_len;
3112
3113 uri->canon_uri[pos] = '/';
3114 uri->canon_uri[pos+1] = '/';
3115 }
3116 uri->canon_len += 2;
3117 }
3118
3119 if(!canonicalize_authority(data, uri, flags, computeOnly))
3120 return FALSE;
3121
3122 if(data->is_relative && (data->password || data->username)) {
3123 if(!canonicalize_path_opaque(data, uri, flags, computeOnly))
3124 return FALSE;
3125 } else {
3126 if(!computeOnly)
3127 uri->path_start = uri->canon_len;
3128 uri->path_len = canonicalize_path_hierarchical(data->path, data->path_len, data->scheme_type, data->host_len != 0,
3129 flags, data->has_implicit_scheme, computeOnly ? NULL : uri->canon_uri+uri->canon_len);
3130 uri->canon_len += uri->path_len;
3131 if(!computeOnly && !uri->path_len)
3132 uri->path_start = -1;
3133 }
3134 } else {
3135 /* Opaque URI's don't have an authority. */
3136 uri->userinfo_start = uri->userinfo_split = -1;
3137 uri->userinfo_len = 0;
3138 uri->host_start = -1;
3139 uri->host_len = 0;
3140 uri->host_type = Uri_HOST_UNKNOWN;
3141 uri->has_port = FALSE;
3142 uri->authority_start = -1;
3143 uri->authority_len = 0;
3144 uri->domain_offset = -1;
3145 uri->port_offset = -1;
3146
3147 if(is_hierarchical_scheme(data->scheme_type)) {
3148 DWORD i;
3149
3150 /* Absolute URIs aren't displayed for known scheme types
3151 * which should be hierarchical URIs.
3152 */
3153 uri->display_modifiers |= URI_DISPLAY_NO_ABSOLUTE_URI;
3154
3155 /* Windows also sets the port for these (if they have one). */
3156 for(i = 0; i < ARRAY_SIZE(default_ports); ++i) {
3157 if(data->scheme_type == default_ports[i].scheme) {
3158 uri->has_port = TRUE;
3159 uri->port = default_ports[i].port;
3160 break;
3161 }
3162 }
3163 }
3164
3165 if(!canonicalize_path_opaque(data, uri, flags, computeOnly))
3166 return FALSE;
3167 }
3168
3169 if(uri->path_start > -1 && !computeOnly)
3170 /* Finding file extensions happens for both types of URIs. */
3171 uri->extension_offset = find_file_extension(uri->canon_uri+uri->path_start, uri->path_len);
3172 else
3173 uri->extension_offset = -1;
3174
3175 return TRUE;
3176}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define FIXME(fmt,...)
Definition: debug.h:114
#define URI_DISPLAY_NO_ABSOLUTE_URI
Definition: uri.c:31
static BOOL canonicalize_authority(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2794
static DWORD canonicalize_path_hierarchical(const WCHAR *path, DWORD path_len, URL_SCHEME scheme_type, BOOL has_host, DWORD flags, BOOL is_implicit_scheme, WCHAR *ret_path)
Definition: uri.c:2844
static const struct @566 default_ports[]
static BOOL is_hierarchical_scheme(URL_SCHEME type)
Definition: uri.c:378
static BOOL canonicalize_path_opaque(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2989
static INT find_file_extension(const WCHAR *path, DWORD path_len)
Definition: uri.c:686
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ URL_SCHEME_WILDCARD
Definition: shlwapi.h:1169
int32_t INT
Definition: typedefs.h:58

Referenced by canonicalize_uri(), and compute_canonicalized_length().

◆ canonicalize_host()

static BOOL canonicalize_host ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2674 of file uri.c.

2674 {
2675 uri->host_start = -1;
2676 uri->host_len = 0;
2677 uri->domain_offset = -1;
2678
2679 if(data->host) {
2680 switch(data->host_type) {
2681 case Uri_HOST_DNS:
2682 uri->host_type = Uri_HOST_DNS;
2683 if(!canonicalize_reg_name(data, uri, flags, computeOnly))
2684 return FALSE;
2685
2686 break;
2687 case Uri_HOST_IPV4:
2688 uri->host_type = Uri_HOST_IPV4;
2689 if(!canonicalize_ipv4address(data, uri, flags, computeOnly))
2690 return FALSE;
2691
2692 break;
2693 case Uri_HOST_IPV6:
2694 if(!canonicalize_ipv6address(data, uri, flags, computeOnly))
2695 return FALSE;
2696
2697 uri->host_type = Uri_HOST_IPV6;
2698 break;
2699 case Uri_HOST_UNKNOWN:
2700 if(data->host_len > 0 || data->scheme_type != URL_SCHEME_FILE) {
2701 uri->host_start = uri->canon_len;
2702
2703 /* Nothing happens to unknown host types. */
2704 if(!computeOnly)
2705 memcpy(uri->canon_uri+uri->canon_len, data->host, data->host_len*sizeof(WCHAR));
2706 uri->canon_len += data->host_len;
2707 uri->host_len = data->host_len;
2708 }
2709
2710 uri->host_type = Uri_HOST_UNKNOWN;
2711 break;
2712 default:
2713 FIXME("(%p %p %x %d): Canonicalization for host type %d not supported.\n", data,
2714 uri, flags, computeOnly, data->host_type);
2715 return FALSE;
2716 }
2717 }
2718
2719 return TRUE;
2720}
static BOOL canonicalize_ipv4address(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2453
static BOOL canonicalize_reg_name(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2306
static BOOL canonicalize_ipv6address(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2562
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
@ URL_SCHEME_FILE
Definition: shlwapi.h:1155

Referenced by canonicalize_authority().

◆ canonicalize_implicit_ipv4address()

static BOOL canonicalize_implicit_ipv4address ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2404 of file uri.c.

2404 {
2405 uri->host_start = uri->canon_len;
2406
2407 TRACE("%u\n", data->implicit_ipv4);
2408 /* For unknown scheme types Windows doesn't convert
2409 * the value into an IP address, but it still considers
2410 * it an IPv4 address.
2411 */
2412 if(data->scheme_type == URL_SCHEME_UNKNOWN) {
2413 if(!computeOnly)
2414 memcpy(uri->canon_uri+uri->canon_len, data->host, data->host_len*sizeof(WCHAR));
2415 uri->canon_len += data->host_len;
2416 } else {
2417 if(!computeOnly)
2418 uri->canon_len += ui2ipv4(uri->canon_uri+uri->canon_len, data->implicit_ipv4);
2419 else
2420 uri->canon_len += ui2ipv4(NULL, data->implicit_ipv4);
2421 }
2422
2423 uri->host_len = uri->canon_len - uri->host_start;
2424 uri->host_type = Uri_HOST_IPV4;
2425
2426 if(!computeOnly)
2427 TRACE("%p %p %x %d): Canonicalized implicit IP address=%s len=%d\n",
2428 data, uri, flags, computeOnly,
2429 debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2430 uri->host_len);
2431
2432 return TRUE;
2433}
static DWORD ui2ipv4(WCHAR *dest, UINT address)
Definition: uri.c:834

Referenced by canonicalize_ipv4address().

◆ canonicalize_ipv4address()

static BOOL canonicalize_ipv4address ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2453 of file uri.c.

2453 {
2454 if(data->has_implicit_ip)
2455 return canonicalize_implicit_ipv4address(data, uri, flags, computeOnly);
2456 else {
2457 uri->host_start = uri->canon_len;
2458
2459 /* Windows only normalizes for known scheme types. */
2460 if(data->scheme_type != URL_SCHEME_UNKNOWN) {
2461 /* parse_data contains a partial or full IPv4 address, so normalize it. */
2462 DWORD i, octetDigitCount = 0, octetCount = 0;
2463 BOOL octetHasDigit = FALSE;
2464
2465 for(i = 0; i < data->host_len; ++i) {
2466 if(data->host[i] == '0' && !octetHasDigit) {
2467 /* Can ignore leading zeros if:
2468 * 1) It isn't the last digit of the octet.
2469 * 2) i+1 != data->host_len
2470 * 3) i+1 != '.'
2471 */
2472 if(octetDigitCount == 2 ||
2473 i+1 == data->host_len ||
2474 data->host[i+1] == '.') {
2475 if(!computeOnly)
2476 uri->canon_uri[uri->canon_len] = data->host[i];
2477 ++uri->canon_len;
2478 TRACE("Adding zero\n");
2479 }
2480 } else if(data->host[i] == '.') {
2481 if(!computeOnly)
2482 uri->canon_uri[uri->canon_len] = data->host[i];
2483 ++uri->canon_len;
2484
2485 octetDigitCount = 0;
2486 octetHasDigit = FALSE;
2487 ++octetCount;
2488 } else {
2489 if(!computeOnly)
2490 uri->canon_uri[uri->canon_len] = data->host[i];
2491 ++uri->canon_len;
2492
2493 ++octetDigitCount;
2494 octetHasDigit = TRUE;
2495 }
2496 }
2497
2498 /* Make sure the canonicalized IP address has 4 dec-octets.
2499 * If doesn't add "0" ones until there is 4;
2500 */
2501 for( ; octetCount < 3; ++octetCount) {
2502 if(!computeOnly) {
2503 uri->canon_uri[uri->canon_len] = '.';
2504 uri->canon_uri[uri->canon_len+1] = '0';
2505 }
2506
2507 uri->canon_len += 2;
2508 }
2509 } else {
2510 /* Windows doesn't normalize addresses in unknown schemes. */
2511 if(!computeOnly)
2512 memcpy(uri->canon_uri+uri->canon_len, data->host, data->host_len*sizeof(WCHAR));
2513 uri->canon_len += data->host_len;
2514 }
2515
2516 uri->host_len = uri->canon_len - uri->host_start;
2517 if(!computeOnly)
2518 TRACE("(%p %p %x %d): Canonicalized IPv4 address, ip=%s len=%d\n",
2519 data, uri, flags, computeOnly,
2520 debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2521 uri->host_len);
2522 }
2523
2524 return TRUE;
2525}
static BOOL canonicalize_implicit_ipv4address(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2404

Referenced by canonicalize_host().

◆ canonicalize_ipv6address()

static BOOL canonicalize_ipv6address ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2562 of file uri.c.

2563 {
2564 uri->host_start = uri->canon_len;
2565
2566 if(data->scheme_type == URL_SCHEME_UNKNOWN) {
2567 if(!computeOnly)
2568 memcpy(uri->canon_uri+uri->canon_len, data->host, data->host_len*sizeof(WCHAR));
2569 uri->canon_len += data->host_len;
2570 } else {
2571 USHORT values[8];
2572 INT elision_start;
2573 DWORD i, elision_len;
2574
2575 if(!ipv6_to_number(&(data->ipv6_address), values)) {
2576 TRACE("(%p %p %x %d): Failed to compute numerical value for IPv6 address.\n",
2577 data, uri, flags, computeOnly);
2578 return FALSE;
2579 }
2580
2581 if(!computeOnly)
2582 uri->canon_uri[uri->canon_len] = '[';
2583 ++uri->canon_len;
2584
2585 /* Find where the elision should occur (if any). */
2586 compute_elision_location(&(data->ipv6_address), values, &elision_start, &elision_len);
2587
2588 TRACE("%p %p %x %d): Elision starts at %d, len=%u\n", data, uri, flags,
2589 computeOnly, elision_start, elision_len);
2590
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);
2596
2597 if(i == elision_start) {
2598 if(!computeOnly) {
2599 uri->canon_uri[uri->canon_len] = ':';
2600 uri->canon_uri[uri->canon_len+1] = ':';
2601 }
2602 uri->canon_len += 2;
2603 }
2604
2605 /* We can ignore the current component if we're in the elision. */
2606 if(in_elision)
2607 continue;
2608
2609 /* We only add a ':' if we're not at i == 0, or when we're at
2610 * the very end of elision range since the ':' colon was handled
2611 * earlier. Otherwise we would end up with ":::" after elision.
2612 */
2613 if(i != 0 && !(elision_start > -1 && i == elision_start+elision_len)) {
2614 if(!computeOnly)
2615 uri->canon_uri[uri->canon_len] = ':';
2616 ++uri->canon_len;
2617 }
2618
2619 if(do_ipv4) {
2620 UINT val;
2621 DWORD len;
2622
2623 /* Combine the two parts of the IPv4 address values. */
2624 val = values[i];
2625 val <<= 16;
2626 val += values[i+1];
2627
2628 if(!computeOnly)
2629 len = ui2ipv4(uri->canon_uri+uri->canon_len, val);
2630 else
2631 len = ui2ipv4(NULL, val);
2632
2633 uri->canon_len += len;
2634 ++i;
2635 } else {
2636 /* Write a regular h16 component to the URI. */
2637
2638 /* Short circuit for the trivial case. */
2639 if(values[i] == 0) {
2640 if(!computeOnly)
2641 uri->canon_uri[uri->canon_len] = '0';
2642 ++uri->canon_len;
2643 } else {
2644 static const WCHAR formatW[] = {'%','x',0};
2645
2646 if(!computeOnly)
2647 uri->canon_len += swprintf(uri->canon_uri+uri->canon_len,
2648 formatW, values[i]);
2649 else {
2650 WCHAR tmp[5];
2651 uri->canon_len += swprintf(tmp, formatW, values[i]);
2652 }
2653 }
2654 }
2655 }
2656
2657 /* Add the closing ']'. */
2658 if(!computeOnly)
2659 uri->canon_uri[uri->canon_len] = ']';
2660 ++uri->canon_len;
2661 }
2662
2663 uri->host_len = uri->canon_len - uri->host_start;
2664
2665 if(!computeOnly)
2666 TRACE("(%p %p %x %d): Canonicalized IPv6 address %s, len=%d\n", data, uri, flags,
2667 computeOnly, debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2668 uri->host_len);
2669
2670 return TRUE;
2671}
static BOOL ipv6_to_number(const ipv6_address *address, USHORT number[8])
Definition: uri.c:888
static void compute_elision_location(const ipv6_address *address, const USHORT values[8], INT *index, DWORD *count)
Definition: uri.c:716
#define swprintf
Definition: precomp.h:40
GLboolean GLenum GLenum GLvoid * values
Definition: glext.h:5666
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
unsigned short USHORT
Definition: pedump.c:61

Referenced by canonicalize_host().

◆ canonicalize_password()

static BOOL canonicalize_password ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2193 of file uri.c.

2193 {
2194 const WCHAR *ptr;
2195
2196 if(!data->password) {
2197 uri->userinfo_split = -1;
2198 return TRUE;
2199 }
2200
2201 if(uri->userinfo_start == -1)
2202 /* Has a password, but, doesn't have a username. */
2203 uri->userinfo_start = uri->canon_len;
2204
2205 uri->userinfo_split = uri->canon_len - uri->userinfo_start;
2206
2207 /* Add the ':' to the userinfo component. */
2208 if(!computeOnly)
2209 uri->canon_uri[uri->canon_len] = ':';
2210 ++uri->canon_len;
2211
2212 for(ptr = data->password; ptr < data->password+data->password_len; ++ptr) {
2213 if(*ptr == '%') {
2214 /* Only decode % encoded values for known scheme types. */
2215 if(data->scheme_type != URL_SCHEME_UNKNOWN) {
2216 /* See if the value really needs decoding. */
2218 if(is_unreserved(val)) {
2219 if(!computeOnly)
2220 uri->canon_uri[uri->canon_len] = val;
2221
2222 ++uri->canon_len;
2223
2224 /* Move pass the hex characters. */
2225 ptr += 2;
2226 continue;
2227 }
2228 }
2229 } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
2230 /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
2231 * is NOT set.
2232 */
2233 if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2234 if(!computeOnly)
2235 pct_encode_val(*ptr, uri->canon_uri + uri->canon_len);
2236
2237 uri->canon_len += 3;
2238 continue;
2239 }
2240 }
2241
2242 if(!computeOnly)
2243 /* Nothing special, so just copy the character over. */
2244 uri->canon_uri[uri->canon_len] = *ptr;
2245 ++uri->canon_len;
2246 }
2247
2248 return TRUE;
2249}
static WCHAR password[]
Definition: url.c:33

Referenced by canonicalize_userinfo().

◆ canonicalize_path_hierarchical()

static DWORD canonicalize_path_hierarchical ( const WCHAR path,
DWORD  path_len,
URL_SCHEME  scheme_type,
BOOL  has_host,
DWORD  flags,
BOOL  is_implicit_scheme,
WCHAR ret_path 
)
static

Definition at line 2844 of file uri.c.

2845 {
2846 const BOOL known_scheme = scheme_type != URL_SCHEME_UNKNOWN;
2847 const BOOL is_file = scheme_type == URL_SCHEME_FILE;
2848 const BOOL is_res = scheme_type == URL_SCHEME_RES;
2849 const WCHAR *ptr;
2850 BOOL escape_pct = FALSE;
2851 DWORD len = 0;
2852
2853 if(!path)
2854 return 0;
2855
2856 ptr = path;
2857
2858 if(is_file && !has_host) {
2859 /* Check if a '/' needs to be appended for the file scheme. */
2860 if(path_len > 1 && is_drive_path(ptr) && !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2861 if(ret_path)
2862 ret_path[len] = '/';
2863 len++;
2864 escape_pct = TRUE;
2865 } else if(*ptr == '/') {
2866 if(!(flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2867 /* Copy the extra '/' over. */
2868 if(ret_path)
2869 ret_path[len] = '/';
2870 len++;
2871 }
2872 ++ptr;
2873 }
2874
2875 if(is_drive_path(ptr)) {
2876 if(ret_path) {
2877 ret_path[len] = *ptr;
2878 /* If there's a '|' after the drive letter, convert it to a ':'. */
2879 ret_path[len+1] = ':';
2880 }
2881 ptr += 2;
2882 len += 2;
2883 }
2884 }
2885
2886 if(!is_file && *path && *path != '/') {
2887 /* Prepend a '/' to the path if it doesn't have one. */
2888 if(ret_path)
2889 ret_path[len] = '/';
2890 len++;
2891 }
2892
2893 for(; ptr < path+path_len; ++ptr) {
2894 BOOL do_default_action = TRUE;
2895
2896 if(*ptr == '%' && !is_res) {
2897 const WCHAR *tmp = ptr;
2898 WCHAR val;
2899
2900 /* Check if the % represents a valid encoded char, or if it needs encoding. */
2901 BOOL force_encode = !check_pct_encoded(&tmp) && is_file && !(flags&Uri_CREATE_FILE_USE_DOS_PATH);
2903
2904 if(force_encode || escape_pct) {
2905 /* Escape the percent sign in the file URI. */
2906 if(ret_path)
2907 pct_encode_val(*ptr, ret_path+len);
2908 len += 3;
2909 do_default_action = FALSE;
2910 } else if((is_unreserved(val) && known_scheme) ||
2911 (is_file && !is_implicit_scheme && (is_unreserved(val) || is_reserved(val) ||
2912 (val && flags&Uri_CREATE_FILE_USE_DOS_PATH && !is_forbidden_dos_path_char(val))))) {
2913 if(ret_path)
2914 ret_path[len] = val;
2915 len++;
2916
2917 ptr += 2;
2918 continue;
2919 }
2920 } else if(*ptr == '/' && is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2921 /* Convert the '/' back to a '\\'. */
2922 if(ret_path)
2923 ret_path[len] = '\\';
2924 len++;
2925 do_default_action = FALSE;
2926 } else if(*ptr == '\\' && known_scheme) {
2927 if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
2928 /* Convert '\\' into a '/'. */
2929 if(ret_path)
2930 ret_path[len] = '/';
2931 len++;
2932 do_default_action = FALSE;
2933 }
2934 } else if(known_scheme && !is_res && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) &&
2935 (!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) {
2936 if(!is_file || !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
2937 /* Escape the forbidden character. */
2938 if(ret_path)
2939 pct_encode_val(*ptr, ret_path+len);
2940 len += 3;
2941 do_default_action = FALSE;
2942 }
2943 }
2944
2945 if(do_default_action) {
2946 if(ret_path)
2947 ret_path[len] = *ptr;
2948 len++;
2949 }
2950 }
2951
2952 /* Removing the dot segments only happens when it's not in
2953 * computeOnly mode and it's not a wildcard scheme. File schemes
2954 * with USE_DOS_PATH set don't get dot segments removed.
2955 */
2956 if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) &&
2957 scheme_type != URL_SCHEME_WILDCARD) {
2958 if(!(flags & Uri_CREATE_NO_CANONICALIZE) && ret_path) {
2959 /* Remove the dot segments (if any) and reset everything to the new
2960 * correct length.
2961 */
2962 len = remove_dot_segments(ret_path, len);
2963 }
2964 }
2965
2966 if(ret_path)
2967 TRACE("Canonicalized path %s len=%d\n", debugstr_wn(ret_path, len), len);
2968 return len;
2969}
static BOOL is_forbidden_dos_path_char(WCHAR val)
Definition: uri.c:279
static BOOL check_pct_encoded(const WCHAR **ptr)
Definition: uri.c:936
static DWORD remove_dot_segments(WCHAR *path, DWORD path_len)
Definition: uri.c:630
static BOOL is_drive_path(const WCHAR *str)
Definition: uri.c:271
static DWORD path_len
Definition: batch.c:31
@ URL_SCHEME_RES
Definition: shlwapi.h:1164

Referenced by canonicalize_hierpart(), and compare_file_paths().

◆ canonicalize_path_opaque()

static BOOL canonicalize_path_opaque ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2989 of file uri.c.

2989 {
2990 const WCHAR *ptr;
2991 const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
2992 const BOOL is_file = data->scheme_type == URL_SCHEME_FILE;
2993 const BOOL is_mk = data->scheme_type == URL_SCHEME_MK;
2994
2995 if(!data->path) {
2996 uri->path_start = -1;
2997 uri->path_len = 0;
2998 return TRUE;
2999 }
3000
3001 uri->path_start = uri->canon_len;
3002
3003 if(is_mk){
3004 /* hijack this flag for SCHEME_MK to tell the function when to start
3005 * converting slashes */
3006 flags |= Uri_CREATE_FILE_USE_DOS_PATH;
3007 }
3008
3009 /* For javascript: URIs, simply copy path part without any canonicalization */
3010 if(data->scheme_type == URL_SCHEME_JAVASCRIPT) {
3011 if(!computeOnly)
3012 memcpy(uri->canon_uri+uri->canon_len, data->path, data->path_len*sizeof(WCHAR));
3013 uri->path_len = data->path_len;
3014 uri->canon_len += data->path_len;
3015 return TRUE;
3016 }
3017
3018 /* Windows doesn't allow a "//" to appear after the scheme
3019 * of a URI, if it's an opaque URI.
3020 */
3021 if(data->scheme && *(data->path) == '/' && *(data->path+1) == '/') {
3022 /* So it inserts a "/." before the "//" if it exists. */
3023 if(!computeOnly) {
3024 uri->canon_uri[uri->canon_len] = '/';
3025 uri->canon_uri[uri->canon_len+1] = '.';
3026 }
3027
3028 uri->canon_len += 2;
3029 }
3030
3031 for(ptr = data->path; ptr < data->path+data->path_len; ++ptr) {
3032 BOOL do_default_action = TRUE;
3033
3034 if(*ptr == '%' && known_scheme) {
3036
3037 if(is_unreserved(val)) {
3038 if(!computeOnly)
3039 uri->canon_uri[uri->canon_len] = val;
3040 ++uri->canon_len;
3041
3042 ptr += 2;
3043 continue;
3044 }
3045 } else if(*ptr == '/' && is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
3046 if(!computeOnly)
3047 uri->canon_uri[uri->canon_len] = '\\';
3048 ++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)) {
3052 /* Convert to a '/'. */
3053 if(!computeOnly)
3054 uri->canon_uri[uri->canon_len] = '/';
3055 ++uri->canon_len;
3056 do_default_action = FALSE;
3057 }
3058 } else if(is_mk && *ptr == ':' && ptr + 1 < data->path + data->path_len && *(ptr + 1) == ':') {
3059 flags &= ~Uri_CREATE_FILE_USE_DOS_PATH;
3060 } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) &&
3061 !(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
3062 if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
3063 if(!computeOnly)
3064 pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
3065 uri->canon_len += 3;
3066 do_default_action = FALSE;
3067 }
3068 }
3069
3070 if(do_default_action) {
3071 if(!computeOnly)
3072 uri->canon_uri[uri->canon_len] = *ptr;
3073 ++uri->canon_len;
3074 }
3075 }
3076
3077 if(is_mk && !computeOnly && !(flags & Uri_CREATE_NO_CANONICALIZE)) {
3078 DWORD new_len = remove_dot_segments(uri->canon_uri + uri->path_start,
3079 uri->canon_len - uri->path_start);
3080 uri->canon_len = uri->path_start + new_len;
3081 }
3082
3083 uri->path_len = uri->canon_len - uri->path_start;
3084
3085 if(!computeOnly)
3086 TRACE("(%p %p %x %d): Canonicalized opaque URI path %s len=%d\n", data, uri, flags, computeOnly,
3087 debugstr_wn(uri->canon_uri+uri->path_start, uri->path_len), uri->path_len);
3088 return TRUE;
3089}
@ URL_SCHEME_MK
Definition: shlwapi.h:1156
@ URL_SCHEME_JAVASCRIPT
Definition: shlwapi.h:1161

Referenced by canonicalize_hierpart().

◆ canonicalize_port()

static BOOL canonicalize_port ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2722 of file uri.c.

2722 {
2723 BOOL has_default_port = FALSE;
2724 USHORT default_port = 0;
2725 DWORD i;
2726
2727 uri->port_offset = -1;
2728
2729 /* Check if the scheme has a default port. */
2730 for(i = 0; i < ARRAY_SIZE(default_ports); ++i) {
2731 if(default_ports[i].scheme == data->scheme_type) {
2732 has_default_port = TRUE;
2733 default_port = default_ports[i].port;
2734 break;
2735 }
2736 }
2737
2738 uri->has_port = data->has_port || has_default_port;
2739
2740 /* Possible cases:
2741 * 1) Has a port which is the default port.
2742 * 2) Has a port (not the default).
2743 * 3) Doesn't have a port, but, scheme has a default port.
2744 * 4) No port.
2745 */
2746 if(has_default_port && data->has_port && data->port_value == default_port) {
2747 /* If it's the default port and this flag isn't set, don't do anything. */
2748 if(flags & Uri_CREATE_NO_CANONICALIZE) {
2749 uri->port_offset = uri->canon_len-uri->authority_start;
2750 if(!computeOnly)
2751 uri->canon_uri[uri->canon_len] = ':';
2752 ++uri->canon_len;
2753
2754 if(data->port) {
2755 /* Copy the original port over. */
2756 if(!computeOnly)
2757 memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR));
2758 uri->canon_len += data->port_len;
2759 } else {
2760 if(!computeOnly)
2761 uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value);
2762 else
2763 uri->canon_len += ui2str(NULL, data->port_value);
2764 }
2765 }
2766
2767 uri->port = default_port;
2768 } else if(data->has_port) {
2769 uri->port_offset = uri->canon_len-uri->authority_start;
2770 if(!computeOnly)
2771 uri->canon_uri[uri->canon_len] = ':';
2772 ++uri->canon_len;
2773
2774 if(flags & Uri_CREATE_NO_CANONICALIZE && data->port) {
2775 /* Copy the original over without changes. */
2776 if(!computeOnly)
2777 memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR));
2778 uri->canon_len += data->port_len;
2779 } else {
2780 if(!computeOnly)
2781 uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value);
2782 else
2783 uri->canon_len += ui2str(NULL, data->port_value);
2784 }
2785
2786 uri->port = data->port_value;
2787 } else if(has_default_port)
2788 uri->port = default_port;
2789
2790 return TRUE;
2791}
static DWORD ui2str(WCHAR *dest, UINT value)
Definition: uri.c:854
URL_SCHEME scheme
Definition: uri.c:198

Referenced by canonicalize_authority().

◆ canonicalize_query()

static BOOL canonicalize_query ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 3188 of file uri.c.

3188 {
3189 const WCHAR *ptr, *end;
3190 const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
3191
3192 if(!data->query) {
3193 uri->query_start = -1;
3194 uri->query_len = 0;
3195 return TRUE;
3196 }
3197
3198 uri->query_start = uri->canon_len;
3199
3200 end = data->query+data->query_len;
3201 for(ptr = data->query; ptr < end; ++ptr) {
3202 if(*ptr == '%') {
3203 if(known_scheme && !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3205 if(is_unreserved(val)) {
3206 if(!computeOnly)
3207 uri->canon_uri[uri->canon_len] = val;
3208 ++uri->canon_len;
3209
3210 ptr += 2;
3211 continue;
3212 }
3213 }
3214 } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) {
3215 if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
3216 !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3217 if(!computeOnly)
3218 pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
3219 uri->canon_len += 3;
3220 continue;
3221 }
3222 }
3223
3224 if(!computeOnly)
3225 uri->canon_uri[uri->canon_len] = *ptr;
3226 ++uri->canon_len;
3227 }
3228
3229 uri->query_len = uri->canon_len - uri->query_start;
3230
3231 if(!computeOnly)
3232 TRACE("(%p %p %x %d): Canonicalized query string %s len=%d\n", data, uri, flags,
3233 computeOnly, debugstr_wn(uri->canon_uri+uri->query_start, uri->query_len),
3234 uri->query_len);
3235 return TRUE;
3236}

Referenced by canonicalize_uri(), and compute_canonicalized_length().

◆ canonicalize_reg_name()

static BOOL canonicalize_reg_name ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2306 of file uri.c.

2307 {
2308 static const WCHAR localhostW[] =
2309 {'l','o','c','a','l','h','o','s','t',0};
2310 const WCHAR *ptr;
2311 const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
2312
2313 if(data->scheme_type == URL_SCHEME_FILE &&
2314 data->host_len == lstrlenW(localhostW)) {
2315 if(!StrCmpNIW(data->host, localhostW, data->host_len)) {
2316 uri->host_start = -1;
2317 uri->host_len = 0;
2318 uri->host_type = Uri_HOST_UNKNOWN;
2319 return TRUE;
2320 }
2321 }
2322
2323 if(data->scheme_type == URL_SCHEME_FILE && flags & Uri_CREATE_FILE_USE_DOS_PATH) {
2324 if(!computeOnly) {
2325 uri->canon_uri[uri->canon_len] = '\\';
2326 uri->canon_uri[uri->canon_len+1] = '\\';
2327 }
2328 uri->canon_len += 2;
2329 uri->authority_start = uri->canon_len;
2330 }
2331
2332 uri->host_start = uri->canon_len;
2333
2334 for(ptr = data->host; ptr < data->host+data->host_len; ++ptr) {
2335 if(*ptr == '%' && known_scheme) {
2337 if(is_unreserved(val)) {
2338 /* If NO_CANONICALIZE is not set, then windows lower cases the
2339 * decoded value.
2340 */
2341 if(!(flags & Uri_CREATE_NO_CANONICALIZE) && iswupper(val)) {
2342 if(!computeOnly)
2343 uri->canon_uri[uri->canon_len] = towlower(val);
2344 } else {
2345 if(!computeOnly)
2346 uri->canon_uri[uri->canon_len] = val;
2347 }
2348 ++uri->canon_len;
2349
2350 /* Skip past the % encoded character. */
2351 ptr += 2;
2352 continue;
2353 } else {
2354 /* Just copy the % over. */
2355 if(!computeOnly)
2356 uri->canon_uri[uri->canon_len] = *ptr;
2357 ++uri->canon_len;
2358 }
2359 } else if(*ptr == '\\') {
2360 /* Only unknown scheme types could have made it here with a '\\' in the host name. */
2361 if(!computeOnly)
2362 uri->canon_uri[uri->canon_len] = *ptr;
2363 ++uri->canon_len;
2364 } else if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && is_ascii(*ptr) &&
2365 !is_unreserved(*ptr) && !is_reserved(*ptr) && known_scheme) {
2366 if(!computeOnly) {
2367 pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
2368
2369 /* The percent encoded value gets lower cased also. */
2370 if(!(flags & Uri_CREATE_NO_CANONICALIZE)) {
2371 uri->canon_uri[uri->canon_len+1] = towlower(uri->canon_uri[uri->canon_len+1]);
2372 uri->canon_uri[uri->canon_len+2] = towlower(uri->canon_uri[uri->canon_len+2]);
2373 }
2374 }
2375
2376 uri->canon_len += 3;
2377 } else {
2378 if(!computeOnly) {
2379 if(!(flags & Uri_CREATE_NO_CANONICALIZE) && known_scheme)
2380 uri->canon_uri[uri->canon_len] = towlower(*ptr);
2381 else
2382 uri->canon_uri[uri->canon_len] = *ptr;
2383 }
2384
2385 ++uri->canon_len;
2386 }
2387 }
2388
2389 uri->host_len = uri->canon_len - uri->host_start;
2390
2391 if(!computeOnly)
2392 TRACE("(%p %p %x %d): Canonicalize reg_name=%s len=%d\n", data, uri, flags,
2393 computeOnly, debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2394 uri->host_len);
2395
2396 if(!computeOnly)
2397 find_domain_name(uri->canon_uri+uri->host_start, uri->host_len,
2398 &(uri->domain_offset));
2399
2400 return TRUE;
2401}
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:311
#define lstrlenW
Definition: compat.h:750
void find_domain_name(const WCHAR *host, DWORD host_len, INT *domain_start)
Definition: uri.c:520
#define iswupper(_c)
Definition: ctype.h:665
static const WCHAR localhostW[]
Definition: notification.c:35
#define towlower(c)
Definition: wctype.h:97
char * host
Definition: whois.c:55

Referenced by canonicalize_host().

◆ canonicalize_scheme()

static BOOL canonicalize_scheme ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 3289 of file uri.c.

3289 {
3290 uri->scheme_start = -1;
3291 uri->scheme_len = 0;
3292
3293 if(!data->scheme) {
3294 /* The only type of URI that doesn't have to have a scheme is a relative
3295 * URI.
3296 */
3297 if(!data->is_relative) {
3298 FIXME("(%p %p %x): Unable to determine the scheme type of %s.\n", data,
3299 uri, flags, debugstr_w(data->uri));
3300 return FALSE;
3301 }
3302 } else {
3303 if(!computeOnly) {
3304 DWORD i;
3305 INT pos = uri->canon_len;
3306
3307 for(i = 0; i < data->scheme_len; ++i) {
3308 /* Scheme name must be lower case after canonicalization. */
3309 uri->canon_uri[i + pos] = towlower(data->scheme[i]);
3310 }
3311
3312 uri->canon_uri[i + pos] = ':';
3313 uri->scheme_start = pos;
3314
3315 TRACE("(%p %p %x): Canonicalized scheme=%s, len=%d.\n", data, uri, flags,
3316 debugstr_wn(uri->canon_uri+uri->scheme_start, data->scheme_len), data->scheme_len);
3317 }
3318
3319 /* This happens in both computation modes. */
3320 uri->canon_len += data->scheme_len + 1;
3321 uri->scheme_len = data->scheme_len;
3322 }
3323 return TRUE;
3324}
#define debugstr_w
Definition: kernel32.h:32

Referenced by canonicalize_uri(), and compute_canonicalized_length().

◆ canonicalize_uri()

static HRESULT canonicalize_uri ( const parse_data data,
Uri uri,
DWORD  flags 
)
static

Definition at line 3373 of file uri.c.

3373 {
3374 INT len;
3375
3376 uri->canon_uri = NULL;
3377 uri->canon_size = uri->canon_len = 0;
3378
3379 TRACE("(%p %p %x): beginning to canonicalize URI %s.\n", data, uri, flags, debugstr_w(data->uri));
3380
3381 /* First try to compute the length of the URI. */
3383 if(len == -1) {
3384 ERR("(%p %p %x): Could not compute the canonicalized length of %s.\n", data, uri, flags,
3385 debugstr_w(data->uri));
3386 return E_INVALIDARG;
3387 }
3388
3389 uri->canon_uri = heap_alloc((len+1)*sizeof(WCHAR));
3390 if(!uri->canon_uri)
3391 return E_OUTOFMEMORY;
3392
3393 uri->canon_size = len;
3395 ERR("(%p %p %x): Unable to canonicalize the scheme of the URI.\n", data, uri, flags);
3396 return E_INVALIDARG;
3397 }
3398 uri->scheme_type = data->scheme_type;
3399
3401 ERR("(%p %p %x): Unable to canonicalize the heirpart of the URI\n", data, uri, flags);
3402 return E_INVALIDARG;
3403 }
3404
3406 ERR("(%p %p %x): Unable to canonicalize query string of the URI.\n",
3407 data, uri, flags);
3408 return E_INVALIDARG;
3409 }
3410
3412 ERR("(%p %p %x): Unable to canonicalize fragment of the URI.\n",
3413 data, uri, flags);
3414 return E_INVALIDARG;
3415 }
3416
3417 /* There's a possibility we didn't use all the space we allocated
3418 * earlier.
3419 */
3420 if(uri->canon_len < uri->canon_size) {
3421 /* This happens if the URI is hierarchical and dot
3422 * segments were removed from its path.
3423 */
3424 WCHAR *tmp = heap_realloc(uri->canon_uri, (uri->canon_len+1)*sizeof(WCHAR));
3425 if(!tmp)
3426 return E_OUTOFMEMORY;
3427
3428 uri->canon_uri = tmp;
3429 uri->canon_size = uri->canon_len;
3430 }
3431
3432 uri->canon_uri[uri->canon_len] = '\0';
3433 TRACE("(%p %p %x): finished canonicalizing the URI. uri=%s\n", data, uri, flags, debugstr_w(uri->canon_uri));
3434
3435 return S_OK;
3436}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define ERR(fmt,...)
Definition: debug.h:113
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static int compute_canonicalized_length(const parse_data *data, DWORD flags)
Definition: uri.c:3332
static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3238
static BOOL canonicalize_scheme(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3289
static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3188
static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3097

Referenced by combine_uri(), CreateUri(), generate_uri(), Marshal_UnmarshalInterface(), and PersistStream_Load().

◆ canonicalize_userinfo()

static BOOL canonicalize_userinfo ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2259 of file uri.c.

2259 {
2260 uri->userinfo_start = uri->userinfo_split = -1;
2261 uri->userinfo_len = 0;
2262
2263 if(!data->username && !data->password)
2264 /* URI doesn't have userinfo, so nothing to do here. */
2265 return TRUE;
2266
2267 if(!canonicalize_username(data, uri, flags, computeOnly))
2268 return FALSE;
2269
2270 if(!canonicalize_password(data, uri, flags, computeOnly))
2271 return FALSE;
2272
2273 uri->userinfo_len = uri->canon_len - uri->userinfo_start;
2274 if(!computeOnly)
2275 TRACE("(%p %p %x %d): Canonicalized userinfo, userinfo_start=%d, userinfo=%s, userinfo_split=%d userinfo_len=%d.\n",
2276 data, uri, flags, computeOnly, uri->userinfo_start, debugstr_wn(uri->canon_uri + uri->userinfo_start, uri->userinfo_len),
2277 uri->userinfo_split, uri->userinfo_len);
2278
2279 /* Now insert the '@' after the userinfo. */
2280 if(!computeOnly)
2281 uri->canon_uri[uri->canon_len] = '@';
2282 ++uri->canon_len;
2283
2284 return TRUE;
2285}
static BOOL canonicalize_username(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2145
static BOOL canonicalize_password(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2193

Referenced by canonicalize_authority().

◆ canonicalize_username()

static BOOL canonicalize_username ( const parse_data data,
Uri uri,
DWORD  flags,
BOOL  computeOnly 
)
static

Definition at line 2145 of file uri.c.

2145 {
2146 const WCHAR *ptr;
2147
2148 if(!data->username) {
2149 uri->userinfo_start = -1;
2150 return TRUE;
2151 }
2152
2153 uri->userinfo_start = uri->canon_len;
2154 for(ptr = data->username; ptr < data->username+data->username_len; ++ptr) {
2155 if(*ptr == '%') {
2156 /* Only decode % encoded values for known scheme types. */
2157 if(data->scheme_type != URL_SCHEME_UNKNOWN) {
2158 /* See if the value really needs decoding. */
2160 if(is_unreserved(val)) {
2161 if(!computeOnly)
2162 uri->canon_uri[uri->canon_len] = val;
2163
2164 ++uri->canon_len;
2165
2166 /* Move pass the hex characters. */
2167 ptr += 2;
2168 continue;
2169 }
2170 }
2171 } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
2172 /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
2173 * is NOT set.
2174 */
2175 if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2176 if(!computeOnly)
2177 pct_encode_val(*ptr, uri->canon_uri + uri->canon_len);
2178
2179 uri->canon_len += 3;
2180 continue;
2181 }
2182 }
2183
2184 if(!computeOnly)
2185 /* Nothing special, so just copy the character over. */
2186 uri->canon_uri[uri->canon_len] = *ptr;
2187 ++uri->canon_len;
2188 }
2189
2190 return TRUE;
2191}
static WCHAR username[]
Definition: url.c:32

Referenced by canonicalize_userinfo().

◆ check_dec_octet()

static BOOL check_dec_octet ( const WCHAR **  ptr)
static

Definition at line 964 of file uri.c.

964 {
965 const WCHAR *c1, *c2, *c3;
966
967 c1 = *ptr;
968 /* A dec-octet must be at least 1 digit long. */
969 if(*c1 < '0' || *c1 > '9')
970 return FALSE;
971
972 ++(*ptr);
973
974 c2 = *ptr;
975 /* Since the 1-digit requirement was met, it doesn't
976 * matter if this is a DIGIT value, it's considered a
977 * dec-octet.
978 */
979 if(*c2 < '0' || *c2 > '9')
980 return TRUE;
981
982 ++(*ptr);
983
984 c3 = *ptr;
985 /* Same explanation as above. */
986 if(*c3 < '0' || *c3 > '9')
987 return TRUE;
988
989 /* Anything > 255 isn't a valid IP dec-octet. */
990 if(*c1 >= '2' && *c2 >= '5' && *c3 >= '5') {
991 *ptr = c1;
992 return FALSE;
993 }
994
995 ++(*ptr);
996 return TRUE;
997}

Referenced by check_ipv4address().

◆ check_hierarchical()

static BOOL check_hierarchical ( const WCHAR **  ptr)
static

Definition at line 293 of file uri.c.

293 {
294 const WCHAR *start = *ptr;
295
296 if(**ptr != '/')
297 return FALSE;
298
299 ++(*ptr);
300 if(**ptr != '/') {
301 *ptr = start;
302 return FALSE;
303 }
304
305 ++(*ptr);
306 return TRUE;
307}
GLuint start
Definition: gl.h:1545

Referenced by is_hierarchical_uri(), and parse_canonicalize().

◆ check_implicit_ipv4()

static BOOL check_implicit_ipv4 ( const WCHAR **  ptr,
UINT val 
)
static

Definition at line 1005 of file uri.c.

1005 {
1006 const WCHAR *start = *ptr;
1007 ULONGLONG ret = 0;
1008 *val = 0;
1009
1010 while(is_num(**ptr)) {
1011 ret = ret*10 + (**ptr - '0');
1012
1013 if(ret > UINT_MAX) {
1014 *ptr = start;
1015 return FALSE;
1016 }
1017 ++(*ptr);
1018 }
1019
1020 if(*ptr == start)
1021 return FALSE;
1022
1023 *val = ret;
1024 return TRUE;
1025}
static BOOL is_num(WCHAR val)
Definition: uri.c:267
#define UINT_MAX
Definition: limits.h:41
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by parse_ipv4address().

◆ check_ipv4address()

static BOOL check_ipv4address ( const WCHAR **  ptr,
BOOL  strict 
)
static

Definition at line 1037 of file uri.c.

1037 {
1038 const WCHAR *start = *ptr;
1039
1040 if(!check_dec_octet(ptr)) {
1041 *ptr = start;
1042 return FALSE;
1043 }
1044
1045 if(**ptr != '.') {
1046 *ptr = start;
1047 return FALSE;
1048 }
1049
1050 ++(*ptr);
1051 if(!check_dec_octet(ptr)) {
1052 *ptr = start;
1053 return FALSE;
1054 }
1055
1056 if(**ptr != '.') {
1057 if(strict) {
1058 *ptr = start;
1059 return FALSE;
1060 } else
1061 return TRUE;
1062 }
1063
1064 ++(*ptr);
1065 if(!check_dec_octet(ptr)) {
1066 *ptr = start;
1067 return FALSE;
1068 }
1069
1070 if(**ptr != '.') {
1071 if(strict) {
1072 *ptr = start;
1073 return FALSE;
1074 } else
1075 return TRUE;
1076 }
1077
1078 ++(*ptr);
1079 if(!check_dec_octet(ptr)) {
1080 *ptr = start;
1081 return FALSE;
1082 }
1083
1084 /* Found a four digit ip address. */
1085 return TRUE;
1086}
static BOOL check_dec_octet(const WCHAR **ptr)
Definition: uri.c:964
static int strict
Definition: error.c:51

Referenced by parse_ipv4address(), and parse_ipv6address().

◆ check_pct_encoded()

static BOOL check_pct_encoded ( const WCHAR **  ptr)
static

Definition at line 936 of file uri.c.

936 {
937 const WCHAR *start = *ptr;
938
939 if(**ptr != '%')
940 return FALSE;
941
942 ++(*ptr);
943 if(!is_hexdigit(**ptr)) {
944 *ptr = start;
945 return FALSE;
946 }
947
948 ++(*ptr);
949 if(!is_hexdigit(**ptr)) {
950 *ptr = start;
951 return FALSE;
952 }
953
954 ++(*ptr);
955 return TRUE;
956}
static BOOL is_hexdigit(WCHAR val)
Definition: uri.c:346

Referenced by canonicalize_path_hierarchical(), parse_fragment(), parse_password(), parse_path_hierarchical(), parse_path_opaque(), parse_query(), parse_reg_name(), and parse_username().

◆ CoInternetCombineIUri()

HRESULT WINAPI CoInternetCombineIUri ( IUri pBaseUri,
IUri pRelativeUri,
DWORD  dwCombineFlags,
IUri **  ppCombinedUri,
DWORD_PTR  dwReserved 
)

Definition at line 6716 of file uri.c.

6718{
6719 HRESULT hr;
6721 Uri *relative, *base;
6722 TRACE("(%p %p %x %p %x)\n", pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6723
6724 if(!ppCombinedUri)
6725 return E_INVALIDARG;
6726
6727 if(!pBaseUri || !pRelativeUri) {
6728 *ppCombinedUri = NULL;
6729 return E_INVALIDARG;
6730 }
6731
6732 relative = get_uri_obj(pRelativeUri);
6733 base = get_uri_obj(pBaseUri);
6734 if(!relative || !base) {
6735 *ppCombinedUri = NULL;
6736 FIXME("(%p %p %x %p %x) Unknown IUri types not supported yet.\n",
6737 pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6738 return E_NOTIMPL;
6739 }
6740
6741 info = get_protocol_info(base->canon_uri);
6742 if(info) {
6744 DWORD result_len = 0;
6745
6746 hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, relative->canon_uri, dwCombineFlags,
6747 result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
6748 IInternetProtocolInfo_Release(info);
6749 if(SUCCEEDED(hr)) {
6750 hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri);
6751 if(SUCCEEDED(hr))
6752 return hr;
6753 }
6754 }
6755
6756 return combine_uri(base, relative, dwCombineFlags, ppCombinedUri, 0);
6757}
IInternetProtocolInfo * get_protocol_info(LPCWSTR url)
Definition: session.c:181
HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
Definition: uri.c:5700
static HRESULT combine_uri(Uri *base, Uri *relative, DWORD flags, IUri **result, DWORD extras)
Definition: uri.c:6450
static Uri * get_uri_obj(IUri *uri)
Definition: uri.c:254
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:50
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:95
WCHAR * canon_uri
Definition: uri.c:61

Referenced by CreateURLMonikerEx2().

◆ CoInternetCombineUrlEx()

HRESULT WINAPI CoInternetCombineUrlEx ( IUri pBaseUri,
LPCWSTR  pwzRelativeUrl,
DWORD  dwCombineFlags,
IUri **  ppCombinedUri,
DWORD_PTR  dwReserved 
)

Definition at line 6762 of file uri.c.

6764{
6765 IUri *relative;
6766 Uri *base;
6767 HRESULT hr;
6769
6770 TRACE("(%p %s %x %p %x)\n", pBaseUri, debugstr_w(pwzRelativeUrl), dwCombineFlags,
6771 ppCombinedUri, (DWORD)dwReserved);
6772
6773 if(!ppCombinedUri)
6774 return E_POINTER;
6775
6776 if(!pwzRelativeUrl) {
6777 *ppCombinedUri = NULL;
6778 return E_UNEXPECTED;
6779 }
6780
6781 if(!pBaseUri) {
6782 *ppCombinedUri = NULL;
6783 return E_INVALIDARG;
6784 }
6785
6786 base = get_uri_obj(pBaseUri);
6787 if(!base) {
6788 *ppCombinedUri = NULL;
6789 FIXME("(%p %s %x %p %x) Unknown IUri's not supported yet.\n", pBaseUri, debugstr_w(pwzRelativeUrl),
6790 dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6791 return E_NOTIMPL;
6792 }
6793
6794 info = get_protocol_info(base->canon_uri);
6795 if(info) {
6797 DWORD result_len = 0;
6798
6799 hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, pwzRelativeUrl, dwCombineFlags,
6800 result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
6801 IInternetProtocolInfo_Release(info);
6802 if(SUCCEEDED(hr)) {
6803 hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri);
6804 if(SUCCEEDED(hr))
6805 return hr;
6806 }
6807 }
6808
6809 hr = CreateUri(pwzRelativeUrl, Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, &relative);
6810 if(FAILED(hr)) {
6811 *ppCombinedUri = NULL;
6812 return hr;
6813 }
6814
6815 hr = combine_uri(base, get_uri_obj(relative), dwCombineFlags, ppCombinedUri, COMBINE_URI_FORCE_FLAG_USE);
6816
6817 IUri_Release(relative);
6818 return hr;
6819}
#define COMBINE_URI_FORCE_FLAG_USE
Definition: uri.c:44
#define E_UNEXPECTED
Definition: winerror.h:2456

Referenced by check_codebase(), combine_url(), create_relative_uri(), CreateURLMonikerEx(), and navigate_url().

◆ CoInternetParseIUri()

HRESULT WINAPI CoInternetParseIUri ( IUri pIUri,
PARSEACTION  ParseAction,
DWORD  dwFlags,
LPWSTR  pwzResult,
DWORD  cchResult,
DWORD pcchResult,
DWORD_PTR  dwReserved 
)

Definition at line 7247 of file uri.c.

7250{
7251 HRESULT hr;
7252 Uri *uri;
7254
7255 TRACE("(%p %d %x %p %d %p %x)\n", pIUri, ParseAction, dwFlags, pwzResult,
7256 cchResult, pcchResult, (DWORD)dwReserved);
7257
7258 if(!pcchResult)
7259 return E_POINTER;
7260
7261 if(!pwzResult || !pIUri) {
7262 *pcchResult = 0;
7263 return E_INVALIDARG;
7264 }
7265
7266 if(!(uri = get_uri_obj(pIUri))) {
7267 *pcchResult = 0;
7268 FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
7269 pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
7270 return E_NOTIMPL;
7271 }
7272
7273 info = get_protocol_info(uri->canon_uri);
7274 if(info) {
7275 hr = IInternetProtocolInfo_ParseUrl(info, uri->canon_uri, ParseAction, dwFlags,
7276 pwzResult, cchResult, pcchResult, 0);
7277 IInternetProtocolInfo_Release(info);
7278 if(SUCCEEDED(hr)) return hr;
7279 }
7280
7281 switch(ParseAction) {
7282 case PARSE_CANONICALIZE:
7283 hr = parse_canonicalize(uri, dwFlags, pwzResult, cchResult, pcchResult);
7284 break;
7285 case PARSE_FRIENDLY:
7286 hr = parse_friendly(pIUri, pwzResult, cchResult, pcchResult);
7287 break;
7288 case PARSE_ROOTDOCUMENT:
7289 hr = parse_rootdocument(uri, pwzResult, cchResult, pcchResult);
7290 break;
7291 case PARSE_DOCUMENT:
7292 hr = parse_document(uri, pwzResult, cchResult, pcchResult);
7293 break;
7294 case PARSE_PATH_FROM_URL:
7295 hr = parse_path_from_url(uri, pwzResult, cchResult, pcchResult);
7296 break;
7297 case PARSE_URL_FROM_PATH:
7298 hr = parse_url_from_path(pIUri, pwzResult, cchResult, pcchResult);
7299 break;
7300 case PARSE_SCHEMA:
7301 hr = parse_schema(pIUri, pwzResult, cchResult, pcchResult);
7302 break;
7303 case PARSE_SITE:
7304 hr = parse_site(pIUri, pwzResult, cchResult, pcchResult);
7305 break;
7306 case PARSE_DOMAIN:
7307 hr = parse_domain(pIUri, pwzResult, cchResult, pcchResult);
7308 break;
7309 case PARSE_LOCATION:
7310 case PARSE_ANCHOR:
7311 hr = parse_anchor(pIUri, pwzResult, cchResult, pcchResult);
7312 break;
7313 case PARSE_SECURITY_URL:
7314 case PARSE_MIME:
7315 case PARSE_SERVER:
7316 case PARSE_SECURITY_DOMAIN:
7317 *pcchResult = 0;
7318 hr = E_FAIL;
7319 break;
7320 default:
7321 *pcchResult = 0;
7322 hr = E_NOTIMPL;
7323 FIXME("(%p %d %x %p %d %p %x) Partial stub.\n", pIUri, ParseAction, dwFlags,
7324 pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
7325 }
7326
7327 return hr;
7328}
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT parse_site(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7160
static HRESULT parse_domain(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7188
static HRESULT parse_anchor(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7216
static HRESULT parse_path_from_url(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7044
static HRESULT parse_rootdocument(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6960
static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6821
static HRESULT parse_document(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7011
static HRESULT parse_url_from_path(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7102
static HRESULT parse_schema(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7131
static HRESULT parse_friendly(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6932
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by FileProtocol_StartEx(), and nsFileURL_GetFile().

◆ combine_uri()

static HRESULT combine_uri ( Uri base,
Uri relative,
DWORD  flags,
IUri **  result,
DWORD  extras 
)
static

Definition at line 6450 of file uri.c.

6450 {
6451 Uri *ret;
6452 HRESULT hr;
6454 Uri *proc_uri = base;
6455 DWORD create_flags = 0, len = 0;
6456
6457 memset(&data, 0, sizeof(parse_data));
6458
6459 /* Base case is when the relative Uri has a scheme name,
6460 * if it does, then 'result' will contain the same data
6461 * as the relative Uri.
6462 */
6463 if(relative->scheme_start > -1) {
6464 data.uri = SysAllocString(relative->raw_uri);
6465 if(!data.uri) {
6466 *result = NULL;
6467 return E_OUTOFMEMORY;
6468 }
6469
6470 parse_uri(&data, Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME);
6471
6472 hr = Uri_Construct(NULL, (void**)&ret);
6473 if(FAILED(hr)) {
6474 *result = NULL;
6475 return hr;
6476 }
6477
6478 if(extras & COMBINE_URI_FORCE_FLAG_USE) {
6480 create_flags |= Uri_CREATE_NO_CANONICALIZE;
6482 create_flags |= Uri_CREATE_NO_DECODE_EXTRA_INFO;
6483 }
6484
6485 ret->raw_uri = data.uri;
6487 if(FAILED(hr)) {
6488 IUri_Release(&ret->IUri_iface);
6489 *result = NULL;
6490 return hr;
6491 }
6492
6494 ret->create_flags = create_flags;
6495
6496 *result = &ret->IUri_iface;
6497 } else {
6498 WCHAR *path = NULL;
6499 DWORD raw_flags = 0;
6500
6501 if(base->scheme_start > -1) {
6502 data.scheme = base->canon_uri+base->scheme_start;
6503 data.scheme_len = base->scheme_len;
6504 data.scheme_type = base->scheme_type;
6505 } else {
6506 data.is_relative = TRUE;
6507 data.scheme_type = URL_SCHEME_UNKNOWN;
6508 create_flags |= Uri_CREATE_ALLOW_RELATIVE;
6509 }
6510
6511 if(relative->authority_start > -1)
6512 proc_uri = relative;
6513
6514 if(proc_uri->authority_start > -1) {
6515 if(proc_uri->userinfo_start > -1 && proc_uri->userinfo_split != 0) {
6516 data.username = proc_uri->canon_uri+proc_uri->userinfo_start;
6517 data.username_len = (proc_uri->userinfo_split > -1) ? proc_uri->userinfo_split : proc_uri->userinfo_len;
6518 }
6519
6520 if(proc_uri->userinfo_split > -1) {
6521 data.password = proc_uri->canon_uri+proc_uri->userinfo_start+proc_uri->userinfo_split+1;
6522 data.password_len = proc_uri->userinfo_len-proc_uri->userinfo_split-1;
6523 }
6524
6525 if(proc_uri->host_start > -1) {
6526 data.host = proc_uri->canon_uri+proc_uri->host_start;
6527 data.host_len = proc_uri->host_len;
6528 data.host_type = proc_uri->host_type;
6529 }
6530
6531 if(proc_uri->has_port) {
6532 data.has_port = TRUE;
6533 data.port_value = proc_uri->port;
6534 }
6535 } else if(base->scheme_type != URL_SCHEME_FILE)
6536 data.is_opaque = TRUE;
6537
6538 if(proc_uri == relative || relative->path_start == -1 || !relative->path_len) {
6539 if(proc_uri->path_start > -1) {
6540 data.path = proc_uri->canon_uri+proc_uri->path_start;
6541 data.path_len = proc_uri->path_len;
6542 } else if(!data.is_opaque) {
6543 /* Just set the path as a '/' if the base didn't have
6544 * one and if it's a hierarchical URI.
6545 */
6546 static const WCHAR slashW[] = {'/',0};
6547 data.path = slashW;
6548 data.path_len = 1;
6549 }
6550
6551 if(relative->query_start > -1)
6552 proc_uri = relative;
6553
6554 if(proc_uri->query_start > -1) {
6555 data.query = proc_uri->canon_uri+proc_uri->query_start;
6556 data.query_len = proc_uri->query_len;
6557 }
6558 } else {
6559 const WCHAR *ptr, **pptr;
6560 DWORD path_offset = 0, path_len = 0;
6561
6562 /* There's two possibilities on what will happen to the path component
6563 * of the result IUri. First, if the relative path begins with a '/'
6564 * then the resulting path will just be the relative path. Second, if
6565 * relative path doesn't begin with a '/' then the base path and relative
6566 * path are merged together.
6567 */
6568 if(relative->path_len && *(relative->canon_uri+relative->path_start) == '/' && data.scheme_type != URL_SCHEME_MK) {
6569 WCHAR *tmp = NULL;
6570 BOOL copy_drive_path = FALSE;
6571
6572 /* If the relative IUri's path starts with a '/', then we
6573 * don't use the base IUri's path. Unless the base IUri
6574 * is a file URI, in which case it uses the drive path of
6575 * the base IUri (if it has any) in the new path.
6576 */
6577 if(base->scheme_type == URL_SCHEME_FILE) {
6578 if(base->path_len > 3 && *(base->canon_uri+base->path_start) == '/' &&
6579 is_drive_path(base->canon_uri+base->path_start+1)) {
6580 path_len += 3;
6581 copy_drive_path = TRUE;
6582 }
6583 }
6584
6585 path_len += relative->path_len;
6586
6587 path = heap_alloc((path_len+1)*sizeof(WCHAR));
6588 if(!path) {
6589 *result = NULL;
6590 return E_OUTOFMEMORY;
6591 }
6592
6593 tmp = path;
6594
6595 /* Copy the base paths, drive path over. */
6596 if(copy_drive_path) {
6597 memcpy(tmp, base->canon_uri+base->path_start, 3*sizeof(WCHAR));
6598 tmp += 3;
6599 }
6600
6601 memcpy(tmp, relative->canon_uri+relative->path_start, relative->path_len*sizeof(WCHAR));
6602 path[path_len] = '\0';
6603 } else {
6604 /* Merge the base path with the relative path. */
6605 hr = merge_paths(&data, base->canon_uri+base->path_start, base->path_len,
6606 relative->canon_uri+relative->path_start, relative->path_len,
6607 &path, &path_len, flags);
6608 if(FAILED(hr)) {
6609 *result = NULL;
6610 return hr;
6611 }
6612
6613 /* If the resulting IUri is a file URI, the drive path isn't
6614 * reduced out when the dot segments are removed.
6615 */
6616 if(path_len >= 3 && data.scheme_type == URL_SCHEME_FILE && !data.host) {
6617 if(*path == '/' && is_drive_path(path+1))
6618 path_offset = 2;
6619 else if(is_drive_path(path))
6620 path_offset = 1;
6621 }
6622 }
6623
6624 /* Check if the dot segments need to be removed from the path. */
6625 if(!(flags & URL_DONT_SIMPLIFY) && !data.is_opaque) {
6626 DWORD offset = (path_offset > 0) ? path_offset+1 : 0;
6628
6629 if(new_len != path_len) {
6630 WCHAR *tmp = heap_realloc(path, (offset+new_len+1)*sizeof(WCHAR));
6631 if(!tmp) {
6632 heap_free(path);
6633 *result = NULL;
6634 return E_OUTOFMEMORY;
6635 }
6636
6637 tmp[new_len+offset] = '\0';
6638 path = tmp;
6639 path_len = new_len+offset;
6640 }
6641 }
6642
6643 if(relative->query_start > -1) {
6644 data.query = relative->canon_uri+relative->query_start;
6645 data.query_len = relative->query_len;
6646 }
6647
6648 /* Make sure the path component is valid. */
6649 ptr = path;
6650 pptr = &ptr;
6651 if((data.is_opaque && !parse_path_opaque(pptr, &data, 0)) ||
6652 (!data.is_opaque && !parse_path_hierarchical(pptr, &data, 0))) {
6653 heap_free(path);
6654 *result = NULL;
6655 return E_INVALIDARG;
6656 }
6657 }
6658
6659 if(relative->fragment_start > -1) {
6660 data.fragment = relative->canon_uri+relative->fragment_start;
6661 data.fragment_len = relative->fragment_len;
6662 }
6663
6665 raw_flags |= RAW_URI_FORCE_PORT_DISP;
6667 raw_flags |= RAW_URI_CONVERT_TO_DOS_PATH;
6668
6669 len = generate_raw_uri(&data, data.uri, raw_flags);
6671 if(!data.uri) {
6672 heap_free(path);
6673 *result = NULL;
6674 return E_OUTOFMEMORY;
6675 }
6676
6677 generate_raw_uri(&data, data.uri, raw_flags);
6678
6679 hr = Uri_Construct(NULL, (void**)&ret);
6680 if(FAILED(hr)) {
6681 SysFreeString(data.uri);
6682 heap_free(path);
6683 *result = NULL;
6684 return hr;
6685 }
6686
6688 create_flags |= Uri_CREATE_NO_CANONICALIZE;
6690 create_flags |= Uri_CREATE_FILE_USE_DOS_PATH;
6691
6692 ret->raw_uri = data.uri;
6694 if(FAILED(hr)) {
6695 IUri_Release(&ret->IUri_iface);
6696 *result = NULL;
6697 return hr;
6698 }
6699
6701 ret->display_modifiers |= URI_DISPLAY_NO_DEFAULT_PORT_AUTH;
6702
6704 ret->create_flags = create_flags;
6705 *result = &ret->IUri_iface;
6706
6707 heap_free(path);
6708 }
6709
6710 return S_OK;
6711}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static const WCHAR slashW[]
Definition: devenum.c:59
#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH
Definition: uri.c:32
static BOOL parse_path_opaque(const WCHAR **ptr, parse_data *data, DWORD flags)
Definition: uri.c:1921
#define RAW_URI_FORCE_PORT_DISP
Definition: uri.c:41
static BOOL parse_path_hierarchical(const WCHAR **ptr, parse_data *data, DWORD flags)
Definition: uri.c:1844
static HRESULT merge_paths(parse_data *data, const WCHAR *base, DWORD base_len, const WCHAR *relative, DWORD relative_len, WCHAR **result, DWORD *result_len, DWORD flags)
Definition: uri.c:6400
#define RAW_URI_CONVERT_TO_DOS_PATH
Definition: uri.c:42
static DWORD generate_raw_uri(const parse_data *data, BSTR uri, DWORD flags)
Definition: uri.c:4042
static BOOL parse_uri(parse_data *data, DWORD flags)
Definition: uri.c:2120
static HRESULT canonicalize_uri(const parse_data *data, Uri *uri, DWORD flags)
Definition: uri.c:3373
GLintptr offset
Definition: glext.h:5920
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:339
#define memset(x, y, z)
Definition: compat.h:39
#define URL_DONT_SIMPLIFY
Definition: shlwapi.h:1214
#define URL_FILE_USE_PATHURL
Definition: shlwapi.h:1226
#define URL_DONT_UNESCAPE_EXTRA_INFO
Definition: shlwapi.h:1218
INT path_start
Definition: uri.c:88
DWORD path_len
Definition: uri.c:89
BSTR raw_uri
Definition: uri.c:58
DWORD query_len
Definition: uri.c:93
INT fragment_start
Definition: uri.c:95
INT query_start
Definition: uri.c:92
BOOL has_port
Definition: uri.c:81
INT userinfo_split
Definition: uri.c:73
INT userinfo_start
Definition: uri.c:71
DWORD fragment_len
Definition: uri.c:96
Uri_HOST_TYPE host_type
Definition: uri.c:77
DWORD host_len
Definition: uri.c:76
INT authority_start
Definition: uri.c:83
INT host_start
Definition: uri.c:75
INT scheme_start
Definition: uri.c:67
DWORD port
Definition: uri.c:80
DWORD userinfo_len
Definition: uri.c:72

Referenced by CoInternetCombineIUri(), and CoInternetCombineUrlEx().

◆ compare_file_paths()

static HRESULT compare_file_paths ( const Uri a,
const Uri b,
BOOL ret 
)
static

Definition at line 3875 of file uri.c.

3876{
3877 WCHAR *canon_path_a, *canon_path_b;
3878 DWORD len_a, len_b;
3879
3880 if(!a->path_len) {
3881 *ret = !b->path_len;
3882 return S_OK;
3883 }
3884
3885 if(!b->path_len) {
3886 *ret = FALSE;
3887 return S_OK;
3888 }
3889
3890 /* Fast path */
3891 if(a->path_len == b->path_len && !_wcsnicmp(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len)) {
3892 *ret = TRUE;
3893 return S_OK;
3894 }
3895
3896 len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, NULL);
3897 len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, NULL);
3898
3899 canon_path_a = heap_alloc(len_a*sizeof(WCHAR));
3900 if(!canon_path_a)
3901 return E_OUTOFMEMORY;
3902 canon_path_b = heap_alloc(len_b*sizeof(WCHAR));
3903 if(!canon_path_b) {
3904 heap_free(canon_path_a);
3905 return E_OUTOFMEMORY;
3906 }
3907
3908 len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, canon_path_a);
3909 len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, canon_path_b);
3910
3911 *ret = len_a == len_b && !_wcsnicmp(canon_path_a, canon_path_b, len_a);
3912
3913 heap_free(canon_path_a);
3914 heap_free(canon_path_b);
3915 return S_OK;
3916}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)

Referenced by compare_uris().

◆ compare_uris()

static HRESULT compare_uris ( const Uri a,
const Uri b,
BOOL ret 
)
static

Definition at line 3923 of file uri.c.

3923 {
3924 const BOOL known_scheme = a->scheme_type != URL_SCHEME_UNKNOWN;
3925 const BOOL are_hierarchical = a->authority_start > -1 && b->authority_start > -1;
3926 HRESULT hres;
3927
3928 *ret = FALSE;
3929
3930 if(a->scheme_type != b->scheme_type)
3931 return S_OK;
3932
3933 /* Only compare the scheme names (if any) if their unknown scheme types. */
3934 if(!known_scheme) {
3935 if((a->scheme_start > -1 && b->scheme_start > -1) &&
3936 (a->scheme_len == b->scheme_len)) {
3937 /* Make sure the schemes are the same. */
3938 if(StrCmpNW(a->canon_uri+a->scheme_start, b->canon_uri+b->scheme_start, a->scheme_len))
3939 return S_OK;
3940 } else if(a->scheme_len != b->scheme_len)
3941 /* One of the Uri's has a scheme name, while the other doesn't. */
3942 return S_OK;
3943 }
3944
3945 /* If they have a userinfo component, perform case sensitive compare. */
3946 if((a->userinfo_start > -1 && b->userinfo_start > -1) &&
3947 (a->userinfo_len == b->userinfo_len)) {
3948 if(StrCmpNW(a->canon_uri+a->userinfo_start, b->canon_uri+b->userinfo_start, a->userinfo_len))
3949 return S_OK;
3950 } else if(a->userinfo_len != b->userinfo_len)
3951 /* One of the Uri's had a userinfo, while the other one doesn't. */
3952 return S_OK;
3953
3954 /* Check if they have a host name. */
3955 if((a->host_start > -1 && b->host_start > -1) &&
3956 (a->host_len == b->host_len)) {
3957 /* Perform a case insensitive compare if they are a known scheme type. */
3958 if(known_scheme) {
3959 if(StrCmpNIW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
3960 return S_OK;
3961 } else if(StrCmpNW(a->canon_uri+a->host_start, b->canon_uri+b->host_start, a->host_len))
3962 return S_OK;
3963 } else if(a->host_len != b->host_len)
3964 /* One of the Uri's had a host, while the other one didn't. */
3965 return S_OK;
3966
3967 if(a->has_port && b->has_port) {
3968 if(a->port != b->port)
3969 return S_OK;
3970 } else if(a->has_port || b->has_port)
3971 /* One had a port, while the other one didn't. */
3972 return S_OK;
3973
3974 /* Windows is weird with how it handles paths. For example
3975 * One URI could be "http://google.com" (after canonicalization)
3976 * and one could be "http://google.com/" and the IsEqual function
3977 * would still evaluate to TRUE, but, only if they are both hierarchical
3978 * URIs.
3979 */
3980 if(a->scheme_type == URL_SCHEME_FILE) {
3981 BOOL cmp;
3982
3984 if(FAILED(hres) || !cmp)
3985 return hres;
3986 } else if((a->path_start > -1 && b->path_start > -1) &&
3987 (a->path_len == b->path_len)) {
3988 if(StrCmpNW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len))
3989 return S_OK;
3990 } else if(are_hierarchical && a->path_len == -1 && b->path_len == 0) {
3991 if(*(a->canon_uri+a->path_start) != '/')
3992 return S_OK;
3993 } else if(are_hierarchical && b->path_len == 1 && a->path_len == 0) {
3994 if(*(b->canon_uri+b->path_start) != '/')
3995 return S_OK;
3996 } else if(a->path_len != b->path_len)
3997 return S_OK;
3998
3999 /* Compare the query strings of the two URIs. */
4000 if((a->query_start > -1 && b->query_start > -1) &&
4001 (a->query_len == b->query_len)) {
4002 if(StrCmpNW(a->canon_uri+a->query_start, b->canon_uri+b->query_start, a->query_len))
4003 return S_OK;
4004 } else if(a->query_len != b->query_len)
4005 return S_OK;
4006
4007 if((a->fragment_start > -1 && b->fragment_start > -1) &&
4008 (a->fragment_len == b->fragment_len)) {
4009 if(StrCmpNW(a->canon_uri+a->fragment_start, b->canon_uri+b->fragment_start, a->fragment_len))
4010 return S_OK;
4011 } else if(a->fragment_len != b->fragment_len)
4012 return S_OK;
4013
4014 /* If we get here, the two URIs are equivalent. */
4015 *ret = TRUE;
4016 return S_OK;
4017}
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:504
static HRESULT compare_file_paths(const Uri *a, const Uri *b, BOOL *ret)
Definition: uri.c:3875
HRESULT hres
Definition: protocol.c:465
#define cmp(status, error)
Definition: error.c:114

Referenced by Uri_IsEqual().

◆ compute_canonicalized_length()

static int compute_canonicalized_length ( const parse_data data,
DWORD  flags 
)
static

Definition at line 3332 of file uri.c.

3332 {
3333 Uri uri;
3334
3335 memset(&uri, 0, sizeof(Uri));
3336
3337 TRACE("(%p %x): Beginning to compute canonicalized length for URI %s\n", data, flags,
3338 debugstr_w(data->uri));
3339
3341 ERR("(%p %x): Failed to compute URI scheme length.\n", data, flags);
3342 return -1;
3343 }
3344
3346 ERR("(%p %x): Failed to compute URI hierpart length.\n", data, flags);
3347 return -1;
3348 }
3349
3351 ERR("(%p %x): Failed to compute query string length.\n", data, flags);
3352 return -1;
3353 }
3354
3356 ERR("(%p %x): Failed to compute fragment length.\n", data, flags);
3357 return -1;
3358 }
3359
3360 TRACE("(%p %x): Finished computing canonicalized URI length. length=%d\n", data, flags, uri.canon_len);
3361
3362 return uri.canon_len;
3363}

Referenced by canonicalize_uri().

◆ compute_elision_location()

static void compute_elision_location ( const ipv6_address address,
const USHORT  values[8],
INT index,
DWORD count 
)
static

Definition at line 716 of file uri.c.

717 {
718 DWORD i, max_len, cur_len;
719 INT max_index, cur_index;
720
721 max_len = cur_len = 0;
722 max_index = cur_index = -1;
723 for(i = 0; i < 8; ++i) {
724 BOOL check_ipv4 = (address->ipv4 && i == 6);
725 BOOL is_end = (check_ipv4 || i == 7);
726
727 if(check_ipv4) {
728 /* Check if the IPv4 address contains only zeros. */
729 if(values[i] == 0 && values[i+1] == 0) {
730 if(cur_index == -1)
731 cur_index = i;
732
733 cur_len += 2;
734 ++i;
735 }
736 } else if(values[i] == 0) {
737 if(cur_index == -1)
738 cur_index = i;
739
740 ++cur_len;
741 }
742
743 if(is_end || values[i] != 0) {
744 /* We only consider it for an elision if it's
745 * more than 1 component long.
746 */
747 if(cur_len > 1 && cur_len > max_len) {
748 /* Found the new elision location. */
749 max_len = cur_len;
750 max_index = cur_index;
751 }
752
753 /* Reset the current range for the next range of zeros. */
754 cur_index = -1;
755 cur_len = 0;
756 }
757 }
758
759 *index = max_index;
760 *count = max_len;
761}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint address
Definition: glext.h:9393
GLuint index
Definition: glext.h:6031

Referenced by canonicalize_ipv6address().

◆ compute_ipv6_comps_size()

static void compute_ipv6_comps_size ( ipv6_address address)
static

Definition at line 445 of file uri.c.

445 {
446 address->components_size = address->h16_count * 2;
447
448 if(address->ipv4)
449 /* IPv4 address is 4 bytes. */
450 address->components_size += 4;
451
452 if(address->elision) {
453 /* An elision can be anywhere from 2 bytes up to 16 bytes.
454 * Its size depends on the size of the h16 and IPv4 components.
455 */
456 address->elision_size = 16 - address->components_size;
457 if(address->elision_size < 2)
458 address->elision_size = 2;
459 } else
460 address->elision_size = 0;
461}

Referenced by parse_ipv6address().

◆ convert_to_dos_path()

static void convert_to_dos_path ( const WCHAR path,
DWORD  path_len,
WCHAR output,
DWORD output_len 
)
static

Definition at line 4019 of file uri.c.

4021{
4022 const WCHAR *ptr = path;
4023
4024 if(path_len > 3 && *ptr == '/' && is_drive_path(path+1))
4025 /* Skip over the leading / before the drive path. */
4026 ++ptr;
4027
4028 for(; ptr < path+path_len; ++ptr) {
4029 if(*ptr == '/') {
4030 if(output)
4031 *output++ = '\\';
4032 (*output_len)++;
4033 } else {
4034 if(output)
4035 *output++ = *ptr;
4036 (*output_len)++;
4037 }
4038 }
4039}

Referenced by generate_raw_uri().

◆ CreateIUriBuilder()

HRESULT WINAPI CreateIUriBuilder ( IUri pIUri,
DWORD  dwFlags,
DWORD_PTR  dwReserved,
IUriBuilder **  ppIUriBuilder 
)

Definition at line 6353 of file uri.c.

6354{
6355 UriBuilder *ret;
6356
6357 TRACE("(%p %x %x %p)\n", pIUri, dwFlags, (DWORD)dwReserved, ppIUriBuilder);
6358
6359 if(!ppIUriBuilder)
6360 return E_POINTER;
6361
6362 ret = heap_alloc_zero(sizeof(UriBuilder));
6363 if(!ret)
6364 return E_OUTOFMEMORY;
6365
6366 ret->IUriBuilder_iface.lpVtbl = &UriBuilderVtbl;
6367 ret->ref = 1;
6368
6369 if(pIUri) {
6370 Uri *uri;
6371
6372 if((uri = get_uri_obj(pIUri))) {
6373 if(!uri->create_flags) {
6374 heap_free(ret);
6375 return E_UNEXPECTED;
6376 }
6377 IUri_AddRef(pIUri);
6378 ret->uri = uri;
6379
6380 if(uri->has_port)
6381 /* Windows doesn't set 'has_port' to TRUE in this case. */
6382 ret->port = uri->port;
6383
6384 } else {
6385 heap_free(ret);
6386 *ppIUriBuilder = NULL;
6387 FIXME("(%p %x %x %p): Unknown IUri types not supported yet.\n", pIUri, dwFlags,
6388 (DWORD)dwReserved, ppIUriBuilder);
6389 return E_NOTIMPL;
6390 }
6391 }
6392
6393 *ppIUriBuilder = &ret->IUriBuilder_iface;
6394 return S_OK;
6395}
static const IUriBuilderVtbl UriBuilderVtbl
Definition: uri.c:6321
Definition: uri.c:99

Referenced by ensure_uri_builder(), get_uri_nofrag(), nsURI_GetPrePath(), UriBuilderFactory_CreateInitializedIUriBuilder(), and UriBuilderFactory_CreateIUriBuilder().

◆ CreateUri()

HRESULT WINAPI CreateUri ( LPCWSTR  pwzURI,
DWORD  dwFlags,
DWORD_PTR  dwReserved,
IUri **  ppURI 
)

Definition at line 5700 of file uri.c.

5701{
5702 const DWORD supported_flags = Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_WILDCARD_SCHEME|
5703 Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_NO_CANONICALIZE|Uri_CREATE_CANONICALIZE|
5704 Uri_CREATE_DECODE_EXTRA_INFO|Uri_CREATE_NO_DECODE_EXTRA_INFO|Uri_CREATE_CRACK_UNKNOWN_SCHEMES|
5705 Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES|Uri_CREATE_PRE_PROCESS_HTML_URI|Uri_CREATE_NO_PRE_PROCESS_HTML_URI|
5706 Uri_CREATE_NO_IE_SETTINGS|Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS|Uri_CREATE_FILE_USE_DOS_PATH;
5707 Uri *ret;
5708 HRESULT hr;
5710
5711 TRACE("(%s %x %x %p)\n", debugstr_w(pwzURI), dwFlags, (DWORD)dwReserved, ppURI);
5712
5713 if(!ppURI)
5714 return E_INVALIDARG;
5715
5716 if(!pwzURI) {
5717 *ppURI = NULL;
5718 return E_INVALIDARG;
5719 }
5720
5721 /* Check for invalid flags. */
5723 *ppURI = NULL;
5724 return E_INVALIDARG;
5725 }
5726
5727 /* Currently unsupported. */
5728 if(dwFlags & ~supported_flags)
5729 FIXME("Ignoring unsupported flag(s) %x\n", dwFlags & ~supported_flags);
5730
5731 hr = Uri_Construct(NULL, (void**)&ret);
5732 if(FAILED(hr)) {
5733 *ppURI = NULL;
5734 return hr;
5735 }
5736
5737 /* Explicitly set the default flags if it doesn't cause a flag conflict. */
5739
5740 /* Pre process the URI, unless told otherwise. */
5741 if(!(dwFlags & Uri_CREATE_NO_PRE_PROCESS_HTML_URI))
5742 ret->raw_uri = pre_process_uri(pwzURI);
5743 else
5744 ret->raw_uri = SysAllocString(pwzURI);
5745
5746 if(!ret->raw_uri) {
5747 heap_free(ret);
5748 return E_OUTOFMEMORY;
5749 }
5750
5751 memset(&data, 0, sizeof(parse_data));
5752 data.uri = ret->raw_uri;
5753
5754 /* Validate and parse the URI into its components. */
5755 if(!parse_uri(&data, dwFlags)) {
5756 /* Encountered an unsupported or invalid URI */
5757 IUri_Release(&ret->IUri_iface);
5758 *ppURI = NULL;
5759 return E_INVALIDARG;
5760 }
5761
5762 /* Canonicalize the URI. */
5764 if(FAILED(hr)) {
5765 IUri_Release(&ret->IUri_iface);
5766 *ppURI = NULL;
5767 return hr;
5768 }
5769
5770 ret->create_flags = dwFlags;
5771
5772 *ppURI = &ret->IUri_iface;
5773 return S_OK;
5774}
static BSTR pre_process_uri(LPCWSTR uri)
Definition: uri.c:767

Referenced by AsyncInstallDistributionUnit(), BindProtocol_Start(), CoInternetCombineIUri(), CoInternetCombineUrlEx(), CoInternetGetSecurityUrlEx(), create_uri(), CreateUriWithFragment(), CreateURLMonikerEx(), FileProtocol_Start(), FtpProtocol_Start(), get_security_id_for_url(), GopherProtocol_Start(), HttpProtocol_Start(), map_url_to_zone(), MkProtocol_Start(), and URLMoniker_Load().

◆ CreateUriWithFragment()

HRESULT WINAPI CreateUriWithFragment ( LPCWSTR  pwzURI,
LPCWSTR  pwzFragment,
DWORD  dwFlags,
DWORD_PTR  dwReserved,
IUri **  ppURI 
)

Definition at line 5795 of file uri.c.

5797{
5798 HRESULT hres;
5799 TRACE("(%s %s %x %x %p)\n", debugstr_w(pwzURI), debugstr_w(pwzFragment), dwFlags, (DWORD)dwReserved, ppURI);
5800
5801 if(!ppURI)
5802 return E_INVALIDARG;
5803
5804 if(!pwzURI) {
5805 *ppURI = NULL;
5806 return E_INVALIDARG;
5807 }
5808
5809 /* Check if a fragment should be appended to the URI string. */
5810 if(pwzFragment) {
5811 WCHAR *uriW;
5812 DWORD uri_len, frag_len;
5813 BOOL add_pound;
5814
5815 /* Check if the original URI already has a fragment component. */
5816 if(StrChrW(pwzURI, '#')) {
5817 *ppURI = NULL;
5818 return E_INVALIDARG;
5819 }
5820
5821 uri_len = lstrlenW(pwzURI);
5822 frag_len = lstrlenW(pwzFragment);
5823
5824 /* If the fragment doesn't start with a '#', one will be added. */
5825 add_pound = *pwzFragment != '#';
5826
5827 if(add_pound)
5828 uriW = heap_alloc((uri_len+frag_len+2)*sizeof(WCHAR));
5829 else
5830 uriW = heap_alloc((uri_len+frag_len+1)*sizeof(WCHAR));
5831
5832 if(!uriW)
5833 return E_OUTOFMEMORY;
5834
5835 memcpy(uriW, pwzURI, uri_len*sizeof(WCHAR));
5836 if(add_pound)
5837 uriW[uri_len++] = '#';
5838 memcpy(uriW+uri_len, pwzFragment, (frag_len+1)*sizeof(WCHAR));
5839
5840 hres = CreateUri(uriW, dwFlags, 0, ppURI);
5841
5842 heap_free(uriW);
5843 } else
5844 /* A fragment string wasn't specified, so just forward the call. */
5845 hres = CreateUri(pwzURI, dwFlags, 0, ppURI);
5846
5847 return hres;
5848}
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
Definition: string.c:468

◆ decode_pct_val()

static WCHAR decode_pct_val ( const WCHAR ptr)
static

Definition at line 483 of file uri.c.

483 {
484 WCHAR ret = '\0';
485
486 if(*ptr == '%' && is_hexdigit(*(ptr + 1)) && is_hexdigit(*(ptr + 2))) {
487 INT a = hex_to_int(*(ptr + 1));
488 INT b = hex_to_int(*(ptr + 2));
489
490 ret = a << 4;
491 ret += b;
492 }
493
494 return ret;
495}
static int hex_to_int(WCHAR val)
Definition: uri.c:464
#define b
Definition: ke_i.h:79

Referenced by canonicalize_fragment(), canonicalize_password(), canonicalize_path_hierarchical(), canonicalize_path_opaque(), canonicalize_query(), canonicalize_reg_name(), canonicalize_username(), parse_canonicalize(), and parse_path_from_url().

◆ destroy_uri_obj()

static void destroy_uri_obj ( Uri This)
inlinestatic

Definition at line 4211 of file uri.c.

4212{
4213 SysFreeString(This->raw_uri);
4214 heap_free(This->canon_uri);
4215 heap_free(This);
4216}

Referenced by Uri_Release().

◆ find_domain_name()

void find_domain_name ( const WCHAR host,
DWORD  host_len,
INT domain_start 
)

Definition at line 520 of file uri.c.

521 {
522 const WCHAR *last_tld, *sec_last_tld, *end, *p;
523
524 end = host+host_len-1;
525
526 *domain_start = -1;
527
528 /* There has to be at least enough room for a '.' followed by a
529 * 3-character TLD for a domain to even exist in the host name.
530 */
531 if(host_len < 4)
532 return;
533
534 for (last_tld = sec_last_tld = NULL, p = host; p <= end; p++)
535 {
536 if (*p == '.')
537 {
538 sec_last_tld = last_tld;
539 last_tld = p;
540 }
541 }
542 if(!last_tld)
543 /* http://hostname -> has no domain name. */
544 return;
545
546 if(!sec_last_tld) {
547 /* If the '.' is at the beginning of the host there
548 * has to be at least 3 characters in the TLD for it
549 * to be valid.
550 * Ex: .com -> .com as the domain name.
551 * .co -> has no domain name.
552 */
553 if(last_tld-host == 0) {
554 if(end-(last_tld-1) < 3)
555 return;
556 } else if(last_tld-host == 3) {
557 DWORD i;
558
559 /* If there are three characters in front of last_tld and
560 * they are on the list of recognized TLDs, then this
561 * host doesn't have a domain (since the host only contains
562 * a TLD name.
563 * Ex: edu.uk -> has no domain name.
564 * foo.uk -> foo.uk as the domain name.
565 */
566 for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) {
568 return;
569 }
570 } else if(last_tld-host < 3)
571 /* Anything less than 3 characters is considered part
572 * of the TLD name.
573 * Ex: ak.uk -> Has no domain name.
574 */
575 return;
576
577 /* Otherwise the domain name is the whole host name. */
578 *domain_start = 0;
579 } else if(end+1-last_tld > 3) {
580 /* If the last_tld has more than 3 characters, then it's automatically
581 * considered the TLD of the domain name.
582 * Ex: www.winehq.org.uk.test -> uk.test as the domain name.
583 */
584 *domain_start = (sec_last_tld+1)-host;
585 } else if(last_tld - (sec_last_tld+1) < 4) {
586 DWORD i;
587 /* If the sec_last_tld is 3 characters long it HAS to be on the list of
588 * recognized to still be considered part of the TLD name, otherwise
589 * it's considered the domain name.
590 * Ex: www.google.com.uk -> google.com.uk as the domain name.
591 * www.google.foo.uk -> foo.uk as the domain name.
592 */
593 if(last_tld - (sec_last_tld+1) == 3) {
594 for(i = 0; i < ARRAY_SIZE(recognized_tlds); ++i) {
595 if(!StrCmpNIW(sec_last_tld+1, recognized_tlds[i].tld_name, 3)) {
596 for (p = sec_last_tld; p > host; p--) if (p[-1] == '.') break;
597 *domain_start = p - host;
598 TRACE("Found domain name %s\n", debugstr_wn(host+*domain_start,
599 (host+host_len)-(host+*domain_start)));
600 return;
601 }
602 }
603
604 *domain_start = (sec_last_tld+1)-host;
605 } else {
606 /* Since the sec_last_tld is less than 3 characters it's considered
607 * part of the TLD.
608 * Ex: www.google.fo.uk -> google.fo.uk as the domain name.
609 */
610 for (p = sec_last_tld; p > host; p--) if (p[-1] == '.') break;
611 *domain_start = p - host;
612 }
613 } else {
614 /* The second to last TLD has more than 3 characters making it
615 * the domain name.
616 * Ex: www.google.test.us -> test.us as the domain name.
617 */
618 *domain_start = (sec_last_tld+1)-host;
619 }
620
621 TRACE("Found domain name %s\n", debugstr_wn(host+*domain_start,
622 (host+host_len)-(host+*domain_start)));
623}
WCHAR tld_name[4]
Definition: uri.c:243
static const struct @567 recognized_tlds[]
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by canonicalize_reg_name(), and search_domain_for_zone().

◆ find_file_extension()

static INT find_file_extension ( const WCHAR path,
DWORD  path_len 
)
static

Definition at line 686 of file uri.c.

686 {
687 const WCHAR *end;
688
689 for(end = path+path_len-1; end >= path && *end != '/' && *end != '\\'; --end) {
690 if(*end == '.')
691 return end-path;
692 }
693
694 return -1;
695}

Referenced by canonicalize_hierpart().

◆ generate_raw_uri()

static DWORD generate_raw_uri ( const parse_data data,
BSTR  uri,
DWORD  flags 
)
static

Definition at line 4042 of file uri.c.

4042 {
4043 DWORD length = 0;
4044
4045 if(data->scheme) {
4046 if(uri) {
4047 memcpy(uri, data->scheme, data->scheme_len*sizeof(WCHAR));
4048 uri[data->scheme_len] = ':';
4049 }
4050 length += data->scheme_len+1;
4051 }
4052
4053 if(!data->is_opaque) {
4054 /* For the "//" which appears before the authority component. */
4055 if(uri) {
4056 uri[length] = '/';
4057 uri[length+1] = '/';
4058 }
4059 length += 2;
4060
4061 /* Check if we need to add the "\\" before the host name
4062 * of a UNC server name in a DOS path.
4063 */
4065 data->scheme_type == URL_SCHEME_FILE && data->host) {
4066 if(uri) {
4067 uri[length] = '\\';
4068 uri[length+1] = '\\';
4069 }
4070 length += 2;
4071 }
4072 }
4073
4074 if(data->username) {
4075 if(uri)
4076 memcpy(uri+length, data->username, data->username_len*sizeof(WCHAR));
4077 length += data->username_len;
4078 }
4079
4080 if(data->password) {
4081 if(uri) {
4082 uri[length] = ':';
4083 memcpy(uri+length+1, data->password, data->password_len*sizeof(WCHAR));
4084 }
4085 length += data->password_len+1;
4086 }
4087
4088 if(data->password || data->username) {
4089 if(uri)
4090 uri[length] = '@';
4091 ++length;
4092 }
4093
4094 if(data->host) {
4095 /* IPv6 addresses get the brackets added around them if they don't already
4096 * have them.
4097 */
4098 const BOOL add_brackets = data->host_type == Uri_HOST_IPV6 && *(data->host) != '[';
4099 if(add_brackets) {
4100 if(uri)
4101 uri[length] = '[';
4102 ++length;
4103 }
4104
4105 if(uri)
4106 memcpy(uri+length, data->host, data->host_len*sizeof(WCHAR));
4107 length += data->host_len;
4108
4109 if(add_brackets) {
4110 if(uri)
4111 uri[length] = ']';
4112 length++;
4113 }
4114 }
4115
4116 if(data->has_port) {
4117 /* The port isn't included in the raw uri if it's the default
4118 * port for the scheme type.
4119 */
4120 DWORD i;
4121 BOOL is_default = FALSE;
4122
4123 for(i = 0; i < ARRAY_SIZE(default_ports); ++i) {
4124 if(data->scheme_type == default_ports[i].scheme &&
4125 data->port_value == default_ports[i].port)
4126 is_default = TRUE;
4127 }
4128
4129 if(!is_default || flags & RAW_URI_FORCE_PORT_DISP) {
4130 if(uri)
4131 uri[length] = ':';
4132 ++length;
4133
4134 if(uri)
4135 length += ui2str(uri+length, data->port_value);
4136 else
4137 length += ui2str(NULL, data->port_value);
4138 }
4139 }
4140
4141 /* Check if a '/' should be added before the path for hierarchical URIs. */
4142 if(!data->is_opaque && data->path && *(data->path) != '/') {
4143 if(uri)
4144 uri[length] = '/';
4145 ++length;
4146 }
4147
4148 if(data->path) {
4149 if(!data->is_opaque && data->scheme_type == URL_SCHEME_FILE &&
4151 DWORD len = 0;
4152
4153 if(uri)
4154 convert_to_dos_path(data->path, data->path_len, uri+length, &len);
4155 else
4156 convert_to_dos_path(data->path, data->path_len, NULL, &len);
4157
4158 length += len;
4159 } else {
4160 if(uri)
4161 memcpy(uri+length, data->path, data->path_len*sizeof(WCHAR));
4162 length += data->path_len;
4163 }
4164 }
4165
4166 if(data->query) {
4167 if(uri)
4168 memcpy(uri+length, data->query, data->query_len*sizeof(WCHAR));
4169 length += data->query_len;
4170 }
4171
4172 if(data->fragment) {
4173 if(uri)
4174 memcpy(uri+length, data->fragment, data->fragment_len*sizeof(WCHAR));
4175 length += data->fragment_len;
4176 }
4177
4178 if(uri)
4179 TRACE("(%p %p): Generated raw uri=%s len=%d\n", data, uri, debugstr_wn(uri, length), length);
4180 else
4181 TRACE("(%p %p): Computed raw uri len=%d\n", data, uri, length);
4182
4183 return length;
4184}
static void convert_to_dos_path(const WCHAR *path, DWORD path_len, WCHAR *output, DWORD *output_len)
Definition: uri.c:4019
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Referenced by combine_uri(), and generate_uri().

◆ generate_uri()

static HRESULT generate_uri ( const UriBuilder builder,
const parse_data data,
Uri uri,
DWORD  flags 
)
static

Definition at line 4186 of file uri.c.

4186 {
4187 HRESULT hr;
4189 uri->raw_uri = SysAllocStringLen(NULL, length);
4190 if(!uri->raw_uri)
4191 return E_OUTOFMEMORY;
4192
4193 generate_raw_uri(data, uri->raw_uri, 0);
4194
4196 if(FAILED(hr)) {
4197 if(hr == E_INVALIDARG)
4198 return INET_E_INVALID_URL;
4199 return hr;
4200 }
4201
4202 uri->create_flags = flags;
4203 return S_OK;
4204}

Referenced by build_uri().

◆ get_builder_component()

static HRESULT get_builder_component ( LPWSTR component,
DWORD component_len,
LPCWSTR  source,
DWORD  source_len,
LPCWSTR output,
DWORD output_len 
)
static

Definition at line 3438 of file uri.c.

3441{
3442 if(!output_len) {
3443 if(output)
3444 *output = NULL;
3445 return E_POINTER;
3446 }
3447
3448 if(!output) {
3449 *output_len = 0;
3450 return E_POINTER;
3451 }
3452
3453 if(!(*component) && source) {
3454 /* Allocate 'component', and copy the contents from 'source'
3455 * into the new allocation.
3456 */
3457 *component = heap_alloc((source_len+1)*sizeof(WCHAR));
3458 if(!(*component))
3459 return E_OUTOFMEMORY;
3460
3461 memcpy(*component, source, source_len*sizeof(WCHAR));
3462 (*component)[source_len] = '\0';
3463 *component_len = source_len;
3464 }
3465
3466 *output = *component;
3467 *output_len = *component_len;
3468 return *output ? S_OK : S_FALSE;
3469}
#define S_FALSE
Definition: winerror.h:2357

Referenced by UriBuilder_GetFragment(), UriBuilder_GetHost(), UriBuilder_GetPassword(), UriBuilder_GetPath(), UriBuilder_GetQuery(), UriBuilder_GetSchemeName(), and UriBuilder_GetUserName().

◆ get_uri_obj()

static Uri * get_uri_obj ( IUri uri)
static

Definition at line 254 of file uri.c.

255{
256 Uri *ret;
258
259 hres = IUri_QueryInterface(uri, &IID_IUriObj, (void**)&ret);
260 return SUCCEEDED(hres) ? ret : NULL;
261}
static const IID IID_IUriObj
Definition: uri.c:48

Referenced by CoInternetCombineIUri(), CoInternetCombineUrlEx(), CoInternetParseIUri(), CreateIUriBuilder(), Uri_IsEqual(), and UriBuilder_SetIUri().

◆ h16tous()

static USHORT h16tous ( h16  component)
static

Definition at line 872 of file uri.c.

872 {
873 DWORD i;
874 USHORT ret = 0;
875
876 for(i = 0; i < component.len; ++i) {
877 ret <<= 4;
878 ret += hex_to_int(component.str[i]);
879 }
880
881 return ret;
882}
DWORD len
Definition: uri.c:133
const WCHAR * str
Definition: uri.c:132

Referenced by ipv6_to_number().

◆ has_invalid_flag_combination()

static BOOL has_invalid_flag_combination ( DWORD  flags)
inlinestatic

Definition at line 387 of file uri.c.

387 {
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));
393}

Referenced by build_uri(), and CreateUri().

◆ hex_to_int()

static int hex_to_int ( WCHAR  val)
static

Definition at line 464 of file uri.c.

464 {
465 if(val >= '0' && val <= '9')
466 return val - '0';
467 else if(val >= 'a' && val <= 'f')
468 return val - 'a' + 10;
469 else if(val >= 'A' && val <= 'F')
470 return val - 'A' + 10;
471
472 return -1;
473}

Referenced by decode_pct_val(), and h16tous().

◆ impl_from_IMarshal()

static Uri * impl_from_IMarshal ( IMarshal iface)
inlinestatic

◆ impl_from_IPersistStream()

static Uri * impl_from_IPersistStream ( IPersistStream iface)
inlinestatic

◆ impl_from_IUri()

◆ impl_from_IUriBuilder()

◆ impl_from_IUriBuilderFactory()

static Uri * impl_from_IUriBuilderFactory ( IUriBuilderFactory iface)
inlinestatic

◆ ipv4toui()

static UINT ipv4toui ( const WCHAR ip,
DWORD  len 
)
static

Definition at line 806 of file uri.c.

806 {
807 UINT ret = 0;
808 DWORD comp_value = 0;
809 const WCHAR *ptr;
810
811 for(ptr = ip; ptr < ip+len; ++ptr) {
812 if(*ptr == '.') {
813 ret <<= 8;
814 ret += comp_value;
815 comp_value = 0;
816 } else
817 comp_value = comp_value*10 + (*ptr-'0');
818 }
819
820 ret <<= 8;
821 ret += comp_value;
822
823 return ret;
824}
static int comp_value(const WCHAR *ptr, int dpc)
Definition: htmlbody.c:68
Definition: dhcpd.h:62

Referenced by ipv6_to_number().

◆ ipv6_to_number()

static BOOL ipv6_to_number ( const ipv6_address address,
USHORT  number[8] 
)
static

Definition at line 888 of file uri.c.

888 {
889 DWORD i, cur_component = 0;
890 BOOL already_passed_elision = FALSE;
891
892 for(i = 0; i < address->h16_count; ++i) {
893 if(address->elision) {
894 if(address->components[i].str > address->elision && !already_passed_elision) {
895 /* Means we just passed the elision and need to add its values to
896 * 'number' before we do anything else.
897 */
898 INT j;
899 for(j = 0; j < address->elision_size; j+=2)
900 number[cur_component++] = 0;
901
902 already_passed_elision = TRUE;
903 }
904 }
905
906 number[cur_component++] = h16tous(address->components[i]);
907 }
908
909 /* Case when the elision appears after the h16 components. */
910 if(!already_passed_elision && address->elision) {
911 INT j;
912 for(j = 0; j < address->elision_size; j+=2)
913 number[cur_component++] = 0;
914 }
915
916 if(address->ipv4) {
917 UINT value = ipv4toui(address->ipv4, address->ipv4_len);
918
919 if(cur_component != 6) {
920 ERR("(%p %p): Failed sanity check with %d\n", address, number, cur_component);
921 return FALSE;
922 }
923
924 number[cur_component++] = (value >> 16) & 0xffff;
925 number[cur_component] = value & 0xffff;
926 }
927
928 return TRUE;
929}
static UINT ipv4toui(const WCHAR *ip, DWORD len)
Definition: uri.c:806
static USHORT h16tous(h16 component)
Definition: uri.c:872
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static unsigned int number
Definition: dsound.c:1479
Definition: pdh_main.c:94

Referenced by canonicalize_ipv6address().

◆ is_alpha()

static BOOL is_alpha ( WCHAR  val)
inlinestatic

Definition at line 263 of file uri.c.

263 {
264 return ((val >= 'a' && val <= 'z') || (val >= 'A' && val <= 'Z'));
265}

◆ is_ascii()

static BOOL is_ascii ( WCHAR  c)
inlinestatic