ReactOS  0.4.13-dev-551-gf37fb1f
uri.c File Reference
#include <limits.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 36 of file uri.c.

◆ ALLOW_NULL_TERM_PASSWORD

#define ALLOW_NULL_TERM_PASSWORD   0x04

Definition at line 35 of file uri.c.

◆ ALLOW_NULL_TERM_SCHEME

#define ALLOW_NULL_TERM_SCHEME   0x01

Definition at line 33 of file uri.c.

◆ ALLOW_NULL_TERM_USER_NAME

#define ALLOW_NULL_TERM_USER_NAME   0x02

Definition at line 34 of file uri.c.

◆ COMBINE_URI_FORCE_FLAG_USE

#define COMBINE_URI_FORCE_FLAG_USE   0x1

Definition at line 43 of file uri.c.

◆ IGNORE_PORT_DELIMITER

#define IGNORE_PORT_DELIMITER   0x20

Definition at line 38 of file uri.c.

◆ NO_SHLWAPI_REG

#define NO_SHLWAPI_REG

Definition at line 25 of file uri.c.

◆ RAW_URI_CONVERT_TO_DOS_PATH

#define RAW_URI_CONVERT_TO_DOS_PATH   0x2

Definition at line 41 of file uri.c.

◆ RAW_URI_FORCE_PORT_DISP

#define RAW_URI_FORCE_PORT_DISP   0x1

Definition at line 40 of file uri.c.

◆ SKIP_IP_FUTURE_CHECK

#define SKIP_IP_FUTURE_CHECK   0x10

Definition at line 37 of file uri.c.

◆ URI_DISPLAY_NO_ABSOLUTE_URI

#define URI_DISPLAY_NO_ABSOLUTE_URI   0x1

Definition at line 30 of file uri.c.

◆ URI_DISPLAY_NO_DEFAULT_PORT_AUTH

#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH   0x2

Definition at line 31 of file uri.c.

Function Documentation

◆ apply_default_flags()

static void apply_default_flags ( DWORD flags)
static

Definition at line 397 of file uri.c.

397  {
398  if(!(*flags & Uri_CREATE_NO_CANONICALIZE))
399  *flags |= Uri_CREATE_CANONICALIZE;
400  if(!(*flags & Uri_CREATE_NO_DECODE_EXTRA_INFO))
401  *flags |= Uri_CREATE_DECODE_EXTRA_INFO;
402  if(!(*flags & Uri_CREATE_NO_CRACK_UNKNOWN_SCHEMES))
403  *flags |= Uri_CREATE_CRACK_UNKNOWN_SCHEMES;
404  if(!(*flags & Uri_CREATE_NO_PRE_PROCESS_HTML_URI))
405  *flags |= Uri_CREATE_PRE_PROCESS_HTML_URI;
406  if(!(*flags & Uri_CREATE_IE_SETTINGS))
407  *flags |= Uri_CREATE_NO_IE_SETTINGS;
408 }
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 5851 of file uri.c.

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

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 2795 of file uri.c.

2795  {
2796  uri->authority_start = uri->canon_len;
2797  uri->authority_len = 0;
2798 
2799  if(!canonicalize_userinfo(data, uri, flags, computeOnly))
2800  return FALSE;
2801 
2802  if(!canonicalize_host(data, uri, flags, computeOnly))
2803  return FALSE;
2804 
2805  if(!canonicalize_port(data, uri, flags, computeOnly))
2806  return FALSE;
2807 
2808  if(uri->host_start != -1 || (data->is_relative && (data->password || data->username)))
2809  uri->authority_len = uri->canon_len - uri->authority_start;
2810  else
2811  uri->authority_start = -1;
2812 
2813  return TRUE;
2814 }
static BOOL canonicalize_host(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2675
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL canonicalize_userinfo(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2260
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static BOOL canonicalize_port(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2723

Referenced by canonicalize_hierpart().

◆ canonicalize_fragment()

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

Definition at line 3239 of file uri.c.

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

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 3098 of file uri.c.

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

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 2675 of file uri.c.

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

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 2405 of file uri.c.

2405  {
2406  uri->host_start = uri->canon_len;
2407 
2408  TRACE("%u\n", data->implicit_ipv4);
2409  /* For unknown scheme types Windows doesn't convert
2410  * the value into an IP address, but it still considers
2411  * it an IPv4 address.
2412  */
2413  if(data->scheme_type == URL_SCHEME_UNKNOWN) {
2414  if(!computeOnly)
2415  memcpy(uri->canon_uri+uri->canon_len, data->host, data->host_len*sizeof(WCHAR));
2416  uri->canon_len += data->host_len;
2417  } else {
2418  if(!computeOnly)
2419  uri->canon_len += ui2ipv4(uri->canon_uri+uri->canon_len, data->implicit_ipv4);
2420  else
2421  uri->canon_len += ui2ipv4(NULL, data->implicit_ipv4);
2422  }
2423 
2424  uri->host_len = uri->canon_len - uri->host_start;
2425  uri->host_type = Uri_HOST_IPV4;
2426 
2427  if(!computeOnly)
2428  TRACE("%p %p %x %d): Canonicalized implicit IP address=%s len=%d\n",
2429  data, uri, flags, computeOnly,
2430  debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2431  uri->host_len);
2432 
2433  return TRUE;
2434 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static DWORD ui2ipv4(WCHAR *dest, UINT address)
Definition: uri.c:835
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define debugstr_wn
Definition: kernel32.h:33

Referenced by canonicalize_ipv4address().

◆ canonicalize_ipv4address()

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

Definition at line 2454 of file uri.c.

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

Referenced by canonicalize_host().

◆ canonicalize_ipv6address()

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

Definition at line 2563 of file uri.c.

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

Referenced by canonicalize_host().

◆ canonicalize_password()

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

Definition at line 2194 of file uri.c.

2194  {
2195  const WCHAR *ptr;
2196 
2197  if(!data->password) {
2198  uri->userinfo_split = -1;
2199  return TRUE;
2200  }
2201 
2202  if(uri->userinfo_start == -1)
2203  /* Has a password, but, doesn't have a username. */
2204  uri->userinfo_start = uri->canon_len;
2205 
2206  uri->userinfo_split = uri->canon_len - uri->userinfo_start;
2207 
2208  /* Add the ':' to the userinfo component. */
2209  if(!computeOnly)
2210  uri->canon_uri[uri->canon_len] = ':';
2211  ++uri->canon_len;
2212 
2213  for(ptr = data->password; ptr < data->password+data->password_len; ++ptr) {
2214  if(*ptr == '%') {
2215  /* Only decode % encoded values for known scheme types. */
2216  if(data->scheme_type != URL_SCHEME_UNKNOWN) {
2217  /* See if the value really needs decoding. */
2219  if(is_unreserved(val)) {
2220  if(!computeOnly)
2221  uri->canon_uri[uri->canon_len] = val;
2222 
2223  ++uri->canon_len;
2224 
2225  /* Move pass the hex characters. */
2226  ptr += 2;
2227  continue;
2228  }
2229  }
2230  } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
2231  /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
2232  * is NOT set.
2233  */
2234  if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2235  if(!computeOnly)
2236  pct_encode_val(*ptr, uri->canon_uri + uri->canon_len);
2237 
2238  uri->canon_len += 3;
2239  continue;
2240  }
2241  }
2242 
2243  if(!computeOnly)
2244  /* Nothing special, so just copy the character over. */
2245  uri->canon_uri[uri->canon_len] = *ptr;
2246  ++uri->canon_len;
2247  }
2248 
2249  return TRUE;
2250 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL is_ascii(WCHAR c)
Definition: uri.c:360
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_reserved(WCHAR val)
Definition: uri.c:341
GLuint GLfloat * val
Definition: glext.h:7180
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:309
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:482
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:503

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 2845 of file uri.c.

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

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 2990 of file uri.c.

2990  {
2991  const WCHAR *ptr;
2992  const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
2993  const BOOL is_file = data->scheme_type == URL_SCHEME_FILE;
2994  const BOOL is_mk = data->scheme_type == URL_SCHEME_MK;
2995 
2996  if(!data->path) {
2997  uri->path_start = -1;
2998  uri->path_len = 0;
2999  return TRUE;
3000  }
3001 
3002  uri->path_start = uri->canon_len;
3003 
3004  if(is_mk){
3005  /* hijack this flag for SCHEME_MK to tell the function when to start
3006  * converting slashes */
3007  flags |= Uri_CREATE_FILE_USE_DOS_PATH;
3008  }
3009 
3010  /* For javascript: URIs, simply copy path part without any canonicalization */
3011  if(data->scheme_type == URL_SCHEME_JAVASCRIPT) {
3012  if(!computeOnly)
3013  memcpy(uri->canon_uri+uri->canon_len, data->path, data->path_len*sizeof(WCHAR));
3014  uri->path_len = data->path_len;
3015  uri->canon_len += data->path_len;
3016  return TRUE;
3017  }
3018 
3019  /* Windows doesn't allow a "//" to appear after the scheme
3020  * of a URI, if it's an opaque URI.
3021  */
3022  if(data->scheme && *(data->path) == '/' && *(data->path+1) == '/') {
3023  /* So it inserts a "/." before the "//" if it exists. */
3024  if(!computeOnly) {
3025  uri->canon_uri[uri->canon_len] = '/';
3026  uri->canon_uri[uri->canon_len+1] = '.';
3027  }
3028 
3029  uri->canon_len += 2;
3030  }
3031 
3032  for(ptr = data->path; ptr < data->path+data->path_len; ++ptr) {
3033  BOOL do_default_action = TRUE;
3034 
3035  if(*ptr == '%' && known_scheme) {
3037 
3038  if(is_unreserved(val)) {
3039  if(!computeOnly)
3040  uri->canon_uri[uri->canon_len] = val;
3041  ++uri->canon_len;
3042 
3043  ptr += 2;
3044  continue;
3045  }
3046  } else if(*ptr == '/' && is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
3047  if(!computeOnly)
3048  uri->canon_uri[uri->canon_len] = '\\';
3049  ++uri->canon_len;
3050  do_default_action = FALSE;
3051  } else if(*ptr == '\\') {
3052  if((data->is_relative || is_mk || is_file) && !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) {
3053  /* Convert to a '/'. */
3054  if(!computeOnly)
3055  uri->canon_uri[uri->canon_len] = '/';
3056  ++uri->canon_len;
3057  do_default_action = FALSE;
3058  }
3059  } else if(is_mk && *ptr == ':' && ptr + 1 < data->path + data->path_len && *(ptr + 1) == ':') {
3060  flags &= ~Uri_CREATE_FILE_USE_DOS_PATH;
3061  } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr) &&
3062  !(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
3063  if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) {
3064  if(!computeOnly)
3065  pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
3066  uri->canon_len += 3;
3067  do_default_action = FALSE;
3068  }
3069  }
3070 
3071  if(do_default_action) {
3072  if(!computeOnly)
3073  uri->canon_uri[uri->canon_len] = *ptr;
3074  ++uri->canon_len;
3075  }
3076  }
3077 
3078  if(is_mk && !computeOnly && !(flags & Uri_CREATE_NO_CANONICALIZE)) {
3079  DWORD new_len = remove_dot_segments(uri->canon_uri + uri->path_start,
3080  uri->canon_len - uri->path_start);
3081  uri->canon_len = uri->path_start + new_len;
3082  }
3083 
3084  uri->path_len = uri->canon_len - uri->path_start;
3085 
3086  if(!computeOnly)
3087  TRACE("(%p %p %x %d): Canonicalized opaque URI path %s len=%d\n", data, uri, flags, computeOnly,
3088  debugstr_wn(uri->canon_uri+uri->path_start, uri->path_len), uri->path_len);
3089  return TRUE;
3090 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL is_ascii(WCHAR c)
Definition: uri.c:360
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_reserved(WCHAR val)
Definition: uri.c:341
GLuint GLfloat * val
Definition: glext.h:7180
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:309
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:482
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define debugstr_wn
Definition: kernel32.h:33
Definition: services.c:325
static DWORD remove_dot_segments(WCHAR *path, DWORD path_len)
Definition: uri.c:631
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:503

Referenced by canonicalize_hierpart().

◆ canonicalize_port()

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

Definition at line 2723 of file uri.c.

2723  {
2724  BOOL has_default_port = FALSE;
2725  USHORT default_port = 0;
2726  DWORD i;
2727 
2728  uri->port_offset = -1;
2729 
2730  /* Check if the scheme has a default port. */
2731  for(i = 0; i < ARRAY_SIZE(default_ports); ++i) {
2732  if(default_ports[i].scheme == data->scheme_type) {
2733  has_default_port = TRUE;
2734  default_port = default_ports[i].port;
2735  break;
2736  }
2737  }
2738 
2739  uri->has_port = data->has_port || has_default_port;
2740 
2741  /* Possible cases:
2742  * 1) Has a port which is the default port.
2743  * 2) Has a port (not the default).
2744  * 3) Doesn't have a port, but, scheme has a default port.
2745  * 4) No port.
2746  */
2747  if(has_default_port && data->has_port && data->port_value == default_port) {
2748  /* If it's the default port and this flag isn't set, don't do anything. */
2749  if(flags & Uri_CREATE_NO_CANONICALIZE) {
2750  uri->port_offset = uri->canon_len-uri->authority_start;
2751  if(!computeOnly)
2752  uri->canon_uri[uri->canon_len] = ':';
2753  ++uri->canon_len;
2754 
2755  if(data->port) {
2756  /* Copy the original port over. */
2757  if(!computeOnly)
2758  memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR));
2759  uri->canon_len += data->port_len;
2760  } else {
2761  if(!computeOnly)
2762  uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value);
2763  else
2764  uri->canon_len += ui2str(NULL, data->port_value);
2765  }
2766  }
2767 
2768  uri->port = default_port;
2769  } else if(data->has_port) {
2770  uri->port_offset = uri->canon_len-uri->authority_start;
2771  if(!computeOnly)
2772  uri->canon_uri[uri->canon_len] = ':';
2773  ++uri->canon_len;
2774 
2775  if(flags & Uri_CREATE_NO_CANONICALIZE && data->port) {
2776  /* Copy the original over without changes. */
2777  if(!computeOnly)
2778  memcpy(uri->canon_uri+uri->canon_len, data->port, data->port_len*sizeof(WCHAR));
2779  uri->canon_len += data->port_len;
2780  } else {
2781  if(!computeOnly)
2782  uri->canon_len += ui2str(uri->canon_uri+uri->canon_len, data->port_value);
2783  else
2784  uri->canon_len += ui2str(NULL, data->port_value);
2785  }
2786 
2787  uri->port = data->port_value;
2788  } else if(has_default_port)
2789  uri->port = default_port;
2790 
2791  return TRUE;
2792 }
URL_SCHEME scheme
Definition: uri.c:197
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
static DWORD ui2str(WCHAR *dest, UINT value)
Definition: uri.c:855
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned short USHORT
Definition: pedump.c:61
#define ARRAY_SIZE(a)
Definition: main.h:24
static const struct @531 default_ports[]

Referenced by canonicalize_authority().

◆ canonicalize_query()

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

Definition at line 3189 of file uri.c.

3189  {
3190  const WCHAR *ptr, *end;
3191  const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
3192 
3193  if(!data->query) {
3194  uri->query_start = -1;
3195  uri->query_len = 0;
3196  return TRUE;
3197  }
3198 
3199  uri->query_start = uri->canon_len;
3200 
3201  end = data->query+data->query_len;
3202  for(ptr = data->query; ptr < end; ++ptr) {
3203  if(*ptr == '%') {
3204  if(known_scheme && !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3206  if(is_unreserved(val)) {
3207  if(!computeOnly)
3208  uri->canon_uri[uri->canon_len] = val;
3209  ++uri->canon_len;
3210 
3211  ptr += 2;
3212  continue;
3213  }
3214  }
3215  } else if(known_scheme && is_ascii(*ptr) && !is_unreserved(*ptr) && !is_reserved(*ptr)) {
3216  if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) &&
3217  !(flags & Uri_CREATE_NO_DECODE_EXTRA_INFO)) {
3218  if(!computeOnly)
3219  pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
3220  uri->canon_len += 3;
3221  continue;
3222  }
3223  }
3224 
3225  if(!computeOnly)
3226  uri->canon_uri[uri->canon_len] = *ptr;
3227  ++uri->canon_len;
3228  }
3229 
3230  uri->query_len = uri->canon_len - uri->query_start;
3231 
3232  if(!computeOnly)
3233  TRACE("(%p %p %x %d): Canonicalized query string %s len=%d\n", data, uri, flags,
3234  computeOnly, debugstr_wn(uri->canon_uri+uri->query_start, uri->query_len),
3235  uri->query_len);
3236  return TRUE;
3237 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL is_ascii(WCHAR c)
Definition: uri.c:360
GLuint GLuint end
Definition: gl.h:1545
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_reserved(WCHAR val)
Definition: uri.c:341
GLuint GLfloat * val
Definition: glext.h:7180
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:309
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:482
#define debugstr_wn
Definition: kernel32.h:33
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:503

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 2307 of file uri.c.

2308  {
2309  static const WCHAR localhostW[] =
2310  {'l','o','c','a','l','h','o','s','t',0};
2311  const WCHAR *ptr;
2312  const BOOL known_scheme = data->scheme_type != URL_SCHEME_UNKNOWN;
2313 
2314  if(data->scheme_type == URL_SCHEME_FILE &&
2315  data->host_len == lstrlenW(localhostW)) {
2316  if(!StrCmpNIW(data->host, localhostW, data->host_len)) {
2317  uri->host_start = -1;
2318  uri->host_len = 0;
2319  uri->host_type = Uri_HOST_UNKNOWN;
2320  return TRUE;
2321  }
2322  }
2323 
2324  if(data->scheme_type == URL_SCHEME_FILE && flags & Uri_CREATE_FILE_USE_DOS_PATH) {
2325  if(!computeOnly) {
2326  uri->canon_uri[uri->canon_len] = '\\';
2327  uri->canon_uri[uri->canon_len+1] = '\\';
2328  }
2329  uri->canon_len += 2;
2330  uri->authority_start = uri->canon_len;
2331  }
2332 
2333  uri->host_start = uri->canon_len;
2334 
2335  for(ptr = data->host; ptr < data->host+data->host_len; ++ptr) {
2336  if(*ptr == '%' && known_scheme) {
2338  if(is_unreserved(val)) {
2339  /* If NO_CANONICALIZE is not set, then windows lower cases the
2340  * decoded value.
2341  */
2342  if(!(flags & Uri_CREATE_NO_CANONICALIZE) && isupperW(val)) {
2343  if(!computeOnly)
2344  uri->canon_uri[uri->canon_len] = tolowerW(val);
2345  } else {
2346  if(!computeOnly)
2347  uri->canon_uri[uri->canon_len] = val;
2348  }
2349  ++uri->canon_len;
2350 
2351  /* Skip past the % encoded character. */
2352  ptr += 2;
2353  continue;
2354  } else {
2355  /* Just copy the % over. */
2356  if(!computeOnly)
2357  uri->canon_uri[uri->canon_len] = *ptr;
2358  ++uri->canon_len;
2359  }
2360  } else if(*ptr == '\\') {
2361  /* Only unknown scheme types could have made it here with a '\\' in the host name. */
2362  if(!computeOnly)
2363  uri->canon_uri[uri->canon_len] = *ptr;
2364  ++uri->canon_len;
2365  } else if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) && is_ascii(*ptr) &&
2366  !is_unreserved(*ptr) && !is_reserved(*ptr) && known_scheme) {
2367  if(!computeOnly) {
2368  pct_encode_val(*ptr, uri->canon_uri+uri->canon_len);
2369 
2370  /* The percent encoded value gets lower cased also. */
2371  if(!(flags & Uri_CREATE_NO_CANONICALIZE)) {
2372  uri->canon_uri[uri->canon_len+1] = tolowerW(uri->canon_uri[uri->canon_len+1]);
2373  uri->canon_uri[uri->canon_len+2] = tolowerW(uri->canon_uri[uri->canon_len+2]);
2374  }
2375  }
2376 
2377  uri->canon_len += 3;
2378  } else {
2379  if(!computeOnly) {
2380  if(!(flags & Uri_CREATE_NO_CANONICALIZE) && known_scheme)
2381  uri->canon_uri[uri->canon_len] = tolowerW(*ptr);
2382  else
2383  uri->canon_uri[uri->canon_len] = *ptr;
2384  }
2385 
2386  ++uri->canon_len;
2387  }
2388  }
2389 
2390  uri->host_len = uri->canon_len - uri->host_start;
2391 
2392  if(!computeOnly)
2393  TRACE("(%p %p %x %d): Canonicalize reg_name=%s len=%d\n", data, uri, flags,
2394  computeOnly, debugstr_wn(uri->canon_uri+uri->host_start, uri->host_len),
2395  uri->host_len);
2396 
2397  if(!computeOnly)
2398  find_domain_name(uri->canon_uri+uri->host_start, uri->host_len,
2399  &(uri->domain_offset));
2400 
2401  return TRUE;
2402 }
static const WCHAR localhostW[]
Definition: notification.c:35
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL is_ascii(WCHAR c)
Definition: uri.c:360
char * host
Definition: whois.c:55
#define lstrlenW
Definition: compat.h:407
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_reserved(WCHAR val)
Definition: uri.c:341
GLuint GLfloat * val
Definition: glext.h:7180
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:309
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
void find_domain_name(const WCHAR *host, DWORD host_len, INT *domain_start)
Definition: uri.c:519
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:482
#define debugstr_wn
Definition: kernel32.h:33
WINE_UNICODE_INLINE int isupperW(WCHAR wc)
Definition: unicode.h:185
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:503
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:311

Referenced by canonicalize_host().

◆ canonicalize_scheme()

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

Definition at line 3290 of file uri.c.

3290  {
3291  uri->scheme_start = -1;
3292  uri->scheme_len = 0;
3293 
3294  if(!data->scheme) {
3295  /* The only type of URI that doesn't have to have a scheme is a relative
3296  * URI.
3297  */
3298  if(!data->is_relative) {
3299  FIXME("(%p %p %x): Unable to determine the scheme type of %s.\n", data,
3300  uri, flags, debugstr_w(data->uri));
3301  return FALSE;
3302  }
3303  } else {
3304  if(!computeOnly) {
3305  DWORD i;
3306  INT pos = uri->canon_len;
3307 
3308  for(i = 0; i < data->scheme_len; ++i) {
3309  /* Scheme name must be lower case after canonicalization. */
3310  uri->canon_uri[i + pos] = tolowerW(data->scheme[i]);
3311  }
3312 
3313  uri->canon_uri[i + pos] = ':';
3314  uri->scheme_start = pos;
3315 
3316  TRACE("(%p %p %x): Canonicalized scheme=%s, len=%d.\n", data, uri, flags,
3317  debugstr_wn(uri->canon_uri+uri->scheme_start, data->scheme_len), data->scheme_len);
3318  }
3319 
3320  /* This happens in both computation modes. */
3321  uri->canon_len += data->scheme_len + 1;
3322  uri->scheme_len = data->scheme_len;
3323  }
3324  return TRUE;
3325 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
int32_t INT
Definition: typedefs.h:56
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
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define debugstr_wn
Definition: kernel32.h:33

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 3374 of file uri.c.

3374  {
3375  INT len;
3376 
3377  uri->canon_uri = NULL;
3378  uri->canon_size = uri->canon_len = 0;
3379 
3380  TRACE("(%p %p %x): beginning to canonicalize URI %s.\n", data, uri, flags, debugstr_w(data->uri));
3381 
3382  /* First try to compute the length of the URI. */
3384  if(len == -1) {
3385  ERR("(%p %p %x): Could not compute the canonicalized length of %s.\n", data, uri, flags,
3386  debugstr_w(data->uri));
3387  return E_INVALIDARG;
3388  }
3389 
3390  uri->canon_uri = heap_alloc((len+1)*sizeof(WCHAR));
3391  if(!uri->canon_uri)
3392  return E_OUTOFMEMORY;
3393 
3394  uri->canon_size = len;
3396  ERR("(%p %p %x): Unable to canonicalize the scheme of the URI.\n", data, uri, flags);
3397  return E_INVALIDARG;
3398  }
3399  uri->scheme_type = data->scheme_type;
3400 
3402  ERR("(%p %p %x): Unable to canonicalize the heirpart of the URI\n", data, uri, flags);
3403  return E_INVALIDARG;
3404  }
3405 
3407  ERR("(%p %p %x): Unable to canonicalize query string of the URI.\n",
3408  data, uri, flags);
3409  return E_INVALIDARG;
3410  }
3411 
3413  ERR("(%p %p %x): Unable to canonicalize fragment of the URI.\n",
3414  data, uri, flags);
3415  return E_INVALIDARG;
3416  }
3417 
3418  /* There's a possibility we didn't use all the space we allocated
3419  * earlier.
3420  */
3421  if(uri->canon_len < uri->canon_size) {
3422  /* This happens if the URI is hierarchical and dot
3423  * segments were removed from its path.
3424  */
3425  WCHAR *tmp = heap_realloc(uri->canon_uri, (uri->canon_len+1)*sizeof(WCHAR));
3426  if(!tmp)
3427  return E_OUTOFMEMORY;
3428 
3429  uri->canon_uri = tmp;
3430  uri->canon_size = uri->canon_len;
3431  }
3432 
3433  uri->canon_uri[uri->canon_len] = '\0';
3434  TRACE("(%p %p %x): finished canonicalizing the URI. uri=%s\n", data, uri, flags, debugstr_w(uri->canon_uri));
3435 
3436  return S_OK;
3437 }
const char * uri
Definition: sec_mgr.c:1594
int32_t INT
Definition: typedefs.h:56
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3239
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3189
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static int compute_canonicalized_length(const parse_data *data, DWORD flags)
Definition: uri.c:3333
static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3098
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
static BOOL canonicalize_scheme(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3290

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 2260 of file uri.c.

2260  {
2261  uri->userinfo_start = uri->userinfo_split = -1;
2262  uri->userinfo_len = 0;
2263 
2264  if(!data->username && !data->password)
2265  /* URI doesn't have userinfo, so nothing to do here. */
2266  return TRUE;
2267 
2268  if(!canonicalize_username(data, uri, flags, computeOnly))
2269  return FALSE;
2270 
2271  if(!canonicalize_password(data, uri, flags, computeOnly))
2272  return FALSE;
2273 
2274  uri->userinfo_len = uri->canon_len - uri->userinfo_start;
2275  if(!computeOnly)
2276  TRACE("(%p %p %x %d): Canonicalized userinfo, userinfo_start=%d, userinfo=%s, userinfo_split=%d userinfo_len=%d.\n",
2277  data, uri, flags, computeOnly, uri->userinfo_start, debugstr_wn(uri->canon_uri + uri->userinfo_start, uri->userinfo_len),
2278  uri->userinfo_split, uri->userinfo_len);
2279 
2280  /* Now insert the '@' after the userinfo. */
2281  if(!computeOnly)
2282  uri->canon_uri[uri->canon_len] = '@';
2283  ++uri->canon_len;
2284 
2285  return TRUE;
2286 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL canonicalize_username(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2146
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define debugstr_wn
Definition: kernel32.h:33
static BOOL canonicalize_password(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:2194

Referenced by canonicalize_authority().

◆ canonicalize_username()

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

Definition at line 2146 of file uri.c.

2146  {
2147  const WCHAR *ptr;
2148 
2149  if(!data->username) {
2150  uri->userinfo_start = -1;
2151  return TRUE;
2152  }
2153 
2154  uri->userinfo_start = uri->canon_len;
2155  for(ptr = data->username; ptr < data->username+data->username_len; ++ptr) {
2156  if(*ptr == '%') {
2157  /* Only decode % encoded values for known scheme types. */
2158  if(data->scheme_type != URL_SCHEME_UNKNOWN) {
2159  /* See if the value really needs decoding. */
2161  if(is_unreserved(val)) {
2162  if(!computeOnly)
2163  uri->canon_uri[uri->canon_len] = val;
2164 
2165  ++uri->canon_len;
2166 
2167  /* Move pass the hex characters. */
2168  ptr += 2;
2169  continue;
2170  }
2171  }
2172  } else if(is_ascii(*ptr) && !is_reserved(*ptr) && !is_unreserved(*ptr) && *ptr != '\\') {
2173  /* Only percent encode forbidden characters if the NO_ENCODE_FORBIDDEN_CHARACTERS flag
2174  * is NOT set.
2175  */
2176  if(!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS)) {
2177  if(!computeOnly)
2178  pct_encode_val(*ptr, uri->canon_uri + uri->canon_len);
2179 
2180  uri->canon_len += 3;
2181  continue;
2182  }
2183  }
2184 
2185  if(!computeOnly)
2186  /* Nothing special, so just copy the character over. */
2187  uri->canon_uri[uri->canon_len] = *ptr;
2188  ++uri->canon_len;
2189  }
2190 
2191  return TRUE;
2192 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL is_ascii(WCHAR c)
Definition: uri.c:360
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_reserved(WCHAR val)
Definition: uri.c:341
GLuint GLfloat * val
Definition: glext.h:7180
static WCHAR username[]
Definition: url.c:32
static BOOL is_unreserved(WCHAR val)
Definition: uri.c:309
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
static WCHAR decode_pct_val(const WCHAR *ptr)
Definition: uri.c:482
static void pct_encode_val(WCHAR val, WCHAR *dest)
Definition: uri.c:503

Referenced by canonicalize_userinfo().

◆ check_dec_octet()

static BOOL check_dec_octet ( const WCHAR **  ptr)
static

Definition at line 965 of file uri.c.

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

Referenced by check_ipv4address().

◆ check_hierarchical()

static BOOL check_hierarchical ( const WCHAR **  ptr)
static

Definition at line 292 of file uri.c.

292  {
293  const WCHAR *start = *ptr;
294 
295  if(**ptr != '/')
296  return FALSE;
297 
298  ++(*ptr);
299  if(**ptr != '/') {
300  *ptr = start;
301  return FALSE;
302  }
303 
304  ++(*ptr);
305  return TRUE;
306 }
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
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 1006 of file uri.c.

1006  {
1007  const WCHAR *start = *ptr;
1008  ULONGLONG ret = 0;
1009  *val = 0;
1010 
1011  while(is_num(**ptr)) {
1012  ret = ret*10 + (**ptr - '0');
1013 
1014  if(ret > UINT_MAX) {
1015  *ptr = start;
1016  return FALSE;
1017  }
1018  ++(*ptr);
1019  }
1020 
1021  if(*ptr == start)
1022  return FALSE;
1023 
1024  *val = ret;
1025  return TRUE;
1026 }
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
GLuint GLfloat * val
Definition: glext.h:7180
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint64_t ULONGLONG
Definition: typedefs.h:65
int ret
#define UINT_MAX
Definition: limits.h:41
static BOOL is_num(WCHAR val)
Definition: uri.c:266
GLuint start
Definition: gl.h:1545

Referenced by parse_ipv4address().

◆ check_ipv4address()

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

Definition at line 1038 of file uri.c.

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

Referenced by parse_ipv4address(), and parse_ipv6address().

◆ check_pct_encoded()

static BOOL check_pct_encoded ( const WCHAR **  ptr)
static

Definition at line 937 of file uri.c.

937  {
938  const WCHAR *start = *ptr;
939 
940  if(**ptr != '%')
941  return FALSE;
942 
943  ++(*ptr);
944  if(!is_hexdigit(**ptr)) {
945  *ptr = start;
946  return FALSE;
947  }
948 
949  ++(*ptr);
950  if(!is_hexdigit(**ptr)) {
951  *ptr = start;
952  return FALSE;
953  }
954 
955  ++(*ptr);
956  return TRUE;
957 }
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
static BOOL is_hexdigit(WCHAR val)
Definition: uri.c:345
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint start
Definition: gl.h:1545

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 6722 of file uri.c.

6724 {
6725  HRESULT hr;
6727  Uri *relative, *base;
6728  TRACE("(%p %p %x %p %x)\n", pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6729 
6730  if(!ppCombinedUri)
6731  return E_INVALIDARG;
6732 
6733  if(!pBaseUri || !pRelativeUri) {
6734  *ppCombinedUri = NULL;
6735  return E_INVALIDARG;
6736  }
6737 
6738  relative = get_uri_obj(pRelativeUri);
6739  base = get_uri_obj(pBaseUri);
6740  if(!relative || !base) {
6741  *ppCombinedUri = NULL;
6742  FIXME("(%p %p %x %p %x) Unknown IUri types not supported yet.\n",
6743  pBaseUri, pRelativeUri, dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6744  return E_NOTIMPL;
6745  }
6746 
6747  info = get_protocol_info(base->canon_uri);
6748  if(info) {
6750  DWORD result_len = 0;
6751 
6752  hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, relative->canon_uri, dwCombineFlags,
6753  result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
6754  IInternetProtocolInfo_Release(info);
6755  if(SUCCEEDED(hr)) {
6756  hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri);
6757  if(SUCCEEDED(hr))
6758  return hr;
6759  }
6760  }
6761 
6762  return combine_uri(base, relative, dwCombineFlags, ppCombinedUri, 0);
6763 }
HRESULT hr
Definition: shlfolder.c:183
IInternetProtocolInfo * get_protocol_info(LPCWSTR url)
Definition: session.c:181
struct _test_info info[]
Definition: SetCursorPos.c:19
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
GLuint base
Definition: 3dtext.c:35
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1380
static HRESULT combine_uri(Uri *base, Uri *relative, DWORD flags, IUri **result, DWORD extras)
Definition: uri.c:6456
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static Uri * get_uri_obj(IUri *uri)
Definition: uri.c:253
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: uri.c:49
WCHAR * canon_uri
Definition: uri.c:60
HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
Definition: uri.c:5701
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CreateURLMonikerEx2().

◆ CoInternetCombineUrlEx()

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

Definition at line 6768 of file uri.c.

6770 {
6771  IUri *relative;
6772  Uri *base;
6773  HRESULT hr;
6775 
6776  TRACE("(%p %s %x %p %x)\n", pBaseUri, debugstr_w(pwzRelativeUrl), dwCombineFlags,
6777  ppCombinedUri, (DWORD)dwReserved);
6778 
6779  if(!ppCombinedUri)
6780  return E_POINTER;
6781 
6782  if(!pwzRelativeUrl) {
6783  *ppCombinedUri = NULL;
6784  return E_UNEXPECTED;
6785  }
6786 
6787  if(!pBaseUri) {
6788  *ppCombinedUri = NULL;
6789  return E_INVALIDARG;
6790  }
6791 
6792  base = get_uri_obj(pBaseUri);
6793  if(!base) {
6794  *ppCombinedUri = NULL;
6795  FIXME("(%p %s %x %p %x) Unknown IUri's not supported yet.\n", pBaseUri, debugstr_w(pwzRelativeUrl),
6796  dwCombineFlags, ppCombinedUri, (DWORD)dwReserved);
6797  return E_NOTIMPL;
6798  }
6799 
6800  info = get_protocol_info(base->canon_uri);
6801  if(info) {
6803  DWORD result_len = 0;
6804 
6805  hr = IInternetProtocolInfo_CombineUrl(info, base->canon_uri, pwzRelativeUrl, dwCombineFlags,
6806  result, INTERNET_MAX_URL_LENGTH+1, &result_len, 0);
6807  IInternetProtocolInfo_Release(info);
6808  if(SUCCEEDED(hr)) {
6809  hr = CreateUri(result, Uri_CREATE_ALLOW_RELATIVE, 0, ppCombinedUri);
6810  if(SUCCEEDED(hr))
6811  return hr;
6812  }
6813  }
6814 
6815  hr = CreateUri(pwzRelativeUrl, Uri_CREATE_ALLOW_RELATIVE|Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, 0, &relative);
6816  if(FAILED(hr)) {
6817  *ppCombinedUri = NULL;
6818  return hr;
6819  }
6820 
6821  hr = combine_uri(base, get_uri_obj(relative), dwCombineFlags, ppCombinedUri, COMBINE_URI_FORCE_FLAG_USE);
6822 
6823  IUri_Release(relative);
6824  return hr;
6825 }
HRESULT hr
Definition: shlfolder.c:183
IInternetProtocolInfo * get_protocol_info(LPCWSTR url)
Definition: session.c:181
struct _test_info info[]
Definition: SetCursorPos.c:19
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
GLuint base
Definition: 3dtext.c:35
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1380
static HRESULT combine_uri(Uri *base, Uri *relative, DWORD flags, IUri **result, DWORD extras)
Definition: uri.c:6456
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static Uri * get_uri_obj(IUri *uri)
Definition: uri.c:253
#define COMBINE_URI_FORCE_FLAG_USE
Definition: uri.c:43
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: uri.c:49
#define E_UNEXPECTED
Definition: winerror.h:2456
HRESULT WINAPI CreateUri(LPCWSTR pwzURI, DWORD dwFlags, DWORD_PTR dwReserved, IUri **ppURI)
Definition: uri.c:5701
#define E_POINTER
Definition: winerror.h:2365
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 7253 of file uri.c.

7256 {
7257  HRESULT hr;
7258  Uri *uri;
7260 
7261  TRACE("(%p %d %x %p %d %p %x)\n", pIUri, ParseAction, dwFlags, pwzResult,
7262  cchResult, pcchResult, (DWORD)dwReserved);
7263 
7264  if(!pcchResult)
7265  return E_POINTER;
7266 
7267  if(!pwzResult || !pIUri) {
7268  *pcchResult = 0;
7269  return E_INVALIDARG;
7270  }
7271 
7272  if(!(uri = get_uri_obj(pIUri))) {
7273  *pcchResult = 0;
7274  FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
7275  pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
7276  return E_NOTIMPL;
7277  }
7278 
7279  info = get_protocol_info(uri->canon_uri);
7280  if(info) {
7281  hr = IInternetProtocolInfo_ParseUrl(info, uri->canon_uri, ParseAction, dwFlags,
7282  pwzResult, cchResult, pcchResult, 0);
7283  IInternetProtocolInfo_Release(info);
7284  if(SUCCEEDED(hr)) return hr;
7285  }
7286 
7287  switch(ParseAction) {
7288  case PARSE_CANONICALIZE:
7289  hr = parse_canonicalize(uri, dwFlags, pwzResult, cchResult, pcchResult);
7290  break;
7291  case PARSE_FRIENDLY:
7292  hr = parse_friendly(pIUri, pwzResult, cchResult, pcchResult);
7293  break;
7294  case PARSE_ROOTDOCUMENT:
7295  hr = parse_rootdocument(uri, pwzResult, cchResult, pcchResult);
7296  break;
7297  case PARSE_DOCUMENT:
7298  hr = parse_document(uri, pwzResult, cchResult, pcchResult);
7299  break;
7300  case PARSE_PATH_FROM_URL:
7301  hr = parse_path_from_url(uri, pwzResult, cchResult, pcchResult);
7302  break;
7303  case PARSE_URL_FROM_PATH:
7304  hr = parse_url_from_path(pIUri, pwzResult, cchResult, pcchResult);
7305  break;
7306  case PARSE_SCHEMA:
7307  hr = parse_schema(pIUri, pwzResult, cchResult, pcchResult);
7308  break;
7309  case PARSE_SITE:
7310  hr = parse_site(pIUri, pwzResult, cchResult, pcchResult);
7311  break;
7312  case PARSE_DOMAIN:
7313  hr = parse_domain(pIUri, pwzResult, cchResult, pcchResult);
7314  break;
7315  case PARSE_LOCATION:
7316  case PARSE_ANCHOR:
7317  hr = parse_anchor(pIUri, pwzResult, cchResult, pcchResult);
7318  break;
7319  case PARSE_SECURITY_URL:
7320  case PARSE_MIME:
7321  case PARSE_SERVER:
7322  case PARSE_SECURITY_DOMAIN:
7323  *pcchResult = 0;
7324  hr = E_FAIL;
7325  break;
7326  default:
7327  *pcchResult = 0;
7328  hr = E_NOTIMPL;
7329  FIXME("(%p %d %x %p %d %p %x) Partial stub.\n", pIUri, ParseAction, dwFlags,
7330  pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
7331  }
7332 
7333  return hr;
7334 }
static HRESULT parse_anchor(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7222
HRESULT hr
Definition: shlfolder.c:183
const char * uri
Definition: sec_mgr.c:1594
static HRESULT parse_path_from_url(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7050
IInternetProtocolInfo * get_protocol_info(LPCWSTR url)
Definition: session.c:181
static HRESULT parse_canonicalize(const Uri *uri, DWORD flags, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6827
static HRESULT parse_schema(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7137
#define E_FAIL
Definition: ddrawi.h:102
struct _test_info info[]
Definition: SetCursorPos.c:19
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
static HRESULT parse_friendly(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6938
static Uri * get_uri_obj(IUri *uri)
Definition: uri.c:253
static HRESULT parse_document(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7017
static HRESULT parse_url_from_path(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7108
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HRESULT parse_domain(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7194
static HRESULT parse_rootdocument(const Uri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:6966
static HRESULT parse_site(IUri *uri, LPWSTR output, DWORD output_len, DWORD *result_len)
Definition: uri.c:7166
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: uri.c:49
#define E_POINTER
Definition: winerror.h:2365
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 6456 of file uri.c.

6456  {
6457  Uri *ret;
6458  HRESULT hr;
6459  parse_data data;
6460  Uri *proc_uri = base;
6461  DWORD create_flags = 0, len = 0;
6462 
6463  memset(&data, 0, sizeof(parse_data));
6464 
6465  /* Base case is when the relative Uri has a scheme name,
6466  * if it does, then 'result' will contain the same data
6467  * as the relative Uri.
6468  */
6469  if(relative->scheme_start > -1) {
6470  data.uri = SysAllocString(relative->raw_uri);
6471  if(!data.uri) {
6472  *result = NULL;
6473  return E_OUTOFMEMORY;
6474  }
6475 
6476  parse_uri(&data, Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME);
6477 
6478  hr = Uri_Construct(NULL, (void**)&ret);
6479  if(FAILED(hr)) {
6480  *result = NULL;
6481  return hr;
6482  }
6483 
6484  if(extras & COMBINE_URI_FORCE_FLAG_USE) {
6485  if(flags & URL_DONT_SIMPLIFY)
6486  create_flags |= Uri_CREATE_NO_CANONICALIZE;
6488  create_flags |= Uri_CREATE_NO_DECODE_EXTRA_INFO;
6489  }
6490 
6491  ret->raw_uri = data.uri;
6493  if(FAILED(hr)) {
6494  IUri_Release(&ret->IUri_iface);
6495  *result = NULL;
6496  return hr;
6497  }
6498 
6500  ret->create_flags = create_flags;
6501 
6502  *result = &ret->IUri_iface;
6503  } else {
6504  WCHAR *path = NULL;
6505  DWORD raw_flags = 0;
6506 
6507  if(base->scheme_start > -1) {
6508  data.scheme = base->canon_uri+base->scheme_start;
6509  data.scheme_len = base->scheme_len;
6510  data.scheme_type = base->scheme_type;
6511  } else {
6512  data.is_relative = TRUE;
6513  data.scheme_type = URL_SCHEME_UNKNOWN;
6514  create_flags |= Uri_CREATE_ALLOW_RELATIVE;
6515  }
6516 
6517  if(relative->authority_start > -1)
6518  proc_uri = relative;
6519 
6520  if(proc_uri->authority_start > -1) {
6521  if(proc_uri->userinfo_start > -1 && proc_uri->userinfo_split != 0) {
6522  data.username = proc_uri->canon_uri+proc_uri->userinfo_start;
6523  data.username_len = (proc_uri->userinfo_split > -1) ? proc_uri->userinfo_split : proc_uri->userinfo_len;
6524  }
6525 
6526  if(proc_uri->userinfo_split > -1) {
6527  data.password = proc_uri->canon_uri+proc_uri->userinfo_start+proc_uri->userinfo_split+1;
6528  data.password_len = proc_uri->userinfo_len-proc_uri->userinfo_split-1;
6529  }
6530 
6531  if(proc_uri->host_start > -1) {
6532  data.host = proc_uri->canon_uri+proc_uri->host_start;
6533  data.host_len = proc_uri->host_len;
6534  data.host_type = proc_uri->host_type;
6535  }
6536 
6537  if(proc_uri->has_port) {
6538  data.has_port = TRUE;
6539  data.port_value = proc_uri->port;
6540  }
6541  } else if(base->scheme_type != URL_SCHEME_FILE)
6542  data.is_opaque = TRUE;
6543 
6544  if(proc_uri == relative || relative->path_start == -1 || !relative->path_len) {
6545  if(proc_uri->path_start > -1) {
6546  data.path = proc_uri->canon_uri+proc_uri->path_start;
6547  data.path_len = proc_uri->path_len;
6548  } else if(!data.is_opaque) {
6549  /* Just set the path as a '/' if the base didn't have
6550  * one and if it's a hierarchical URI.
6551  */
6552  static const WCHAR slashW[] = {'/',0};
6553  data.path = slashW;
6554  data.path_len = 1;
6555  }
6556 
6557  if(relative->query_start > -1)
6558  proc_uri = relative;
6559 
6560  if(proc_uri->query_start > -1) {
6561  data.query = proc_uri->canon_uri+proc_uri->query_start;
6562  data.query_len = proc_uri->query_len;
6563  }
6564  } else {
6565  const WCHAR *ptr, **pptr;
6566  DWORD path_offset = 0, path_len = 0;
6567 
6568  /* There's two possibilities on what will happen to the path component
6569  * of the result IUri. First, if the relative path begins with a '/'
6570  * then the resulting path will just be the relative path. Second, if
6571  * relative path doesn't begin with a '/' then the base path and relative
6572  * path are merged together.
6573  */
6574  if(relative->path_len && *(relative->canon_uri+relative->path_start) == '/' && data.scheme_type != URL_SCHEME_MK) {
6575  WCHAR *tmp = NULL;
6576  BOOL copy_drive_path = FALSE;
6577 
6578  /* If the relative IUri's path starts with a '/', then we
6579  * don't use the base IUri's path. Unless the base IUri
6580  * is a file URI, in which case it uses the drive path of
6581  * the base IUri (if it has any) in the new path.
6582  */
6583  if(base->scheme_type == URL_SCHEME_FILE) {
6584  if(base->path_len > 3 && *(base->canon_uri+base->path_start) == '/' &&
6585  is_drive_path(base->canon_uri+base->path_start+1)) {
6586  path_len += 3;
6587  copy_drive_path = TRUE;
6588  }
6589  }
6590 
6591  path_len += relative->path_len;
6592 
6593  path = heap_alloc((path_len+1)*sizeof(WCHAR));
6594  if(!path) {
6595  *result = NULL;
6596  return E_OUTOFMEMORY;
6597  }
6598 
6599  tmp = path;
6600 
6601  /* Copy the base paths, drive path over. */
6602  if(copy_drive_path) {
6603  memcpy(tmp, base->canon_uri+base->path_start, 3*sizeof(WCHAR));
6604  tmp += 3;
6605  }
6606 
6607  memcpy(tmp, relative->canon_uri+relative->path_start, relative->path_len*sizeof(WCHAR));
6608  path[path_len] = '\0';
6609  } else {
6610  /* Merge the base path with the relative path. */
6611  hr = merge_paths(&data, base->canon_uri+base->path_start, base->path_len,
6612  relative->canon_uri+relative->path_start, relative->path_len,
6613  &path, &path_len, flags);
6614  if(FAILED(hr)) {
6615  *result = NULL;
6616  return hr;
6617  }
6618 
6619  /* If the resulting IUri is a file URI, the drive path isn't
6620  * reduced out when the dot segments are removed.
6621  */
6622  if(path_len >= 3 && data.scheme_type == URL_SCHEME_FILE && !data.host) {
6623  if(*path == '/' && is_drive_path(path+1))
6624  path_offset = 2;
6625  else if(is_drive_path(path))
6626  path_offset = 1;
6627  }
6628  }
6629 
6630  /* Check if the dot segments need to be removed from the path. */
6631  if(!(flags & URL_DONT_SIMPLIFY) && !data.is_opaque) {
6632  DWORD offset = (path_offset > 0) ? path_offset+1 : 0;
6634 
6635  if(new_len != path_len) {
6636  WCHAR *tmp = heap_realloc(path, (offset+new_len+1)*sizeof(WCHAR));
6637  if(!tmp) {
6638  heap_free(path);
6639  *result = NULL;
6640  return E_OUTOFMEMORY;
6641  }
6642 
6643  tmp[new_len+offset] = '\0';
6644  path = tmp;
6645  path_len = new_len+offset;
6646  }
6647  }
6648 
6649  if(relative->query_start > -1) {
6650  data.query = relative->canon_uri+relative->query_start;
6651  data.query_len = relative->query_len;
6652  }
6653 
6654  /* Make sure the path component is valid. */
6655  ptr = path;
6656  pptr = &ptr;
6657  if((data.is_opaque && !parse_path_opaque(pptr, &data, 0)) ||
6658  (!data.is_opaque && !parse_path_hierarchical(pptr, &data, 0))) {
6659  heap_free(path);
6660  *result = NULL;
6661  return E_INVALIDARG;
6662  }
6663  }
6664 
6665  if(relative->fragment_start > -1) {
6666  data.fragment = relative->canon_uri+relative->fragment_start;
6667  data.fragment_len = relative->fragment_len;
6668  }
6669 
6670  if(flags & URL_DONT_SIMPLIFY)
6671  raw_flags |= RAW_URI_FORCE_PORT_DISP;
6673  raw_flags |= RAW_URI_CONVERT_TO_DOS_PATH;
6674 
6675  len = generate_raw_uri(&data, data.uri, raw_flags);
6676  data.uri = SysAllocStringLen(NULL, len);
6677  if(!data.uri) {
6678  heap_free(path);
6679  *result = NULL;
6680  return E_OUTOFMEMORY;
6681  }
6682 
6683  generate_raw_uri(&data, data.uri, raw_flags);
6684 
6685  hr = Uri_Construct(NULL, (void**)&ret);
6686  if(FAILED(hr)) {
6687  SysFreeString(data.uri);
6688  heap_free(path);
6689  *result = NULL;
6690  return hr;
6691  }
6692 
6693  if(flags & URL_DONT_SIMPLIFY)
6694  create_flags |= Uri_CREATE_NO_CANONICALIZE;
6696  create_flags |= Uri_CREATE_FILE_USE_DOS_PATH;
6697 
6698  ret->raw_uri = data.uri;
6700  if(FAILED(hr)) {
6701  IUri_Release(&ret->IUri_iface);
6702  *result = NULL;
6703  return hr;
6704  }
6705 
6706  if(flags & URL_DONT_SIMPLIFY)
6707  ret->display_modifiers |= URI_DISPLAY_NO_DEFAULT_PORT_AUTH;
6708 
6710  ret->create_flags = create_flags;
6711  *result = &ret->IUri_iface;
6712 
6713  heap_free(path);
6714  }
6715 
6716  return S_OK;
6717 }
BSTR raw_uri
Definition: uri.c:57
static BOOL parse_path_hierarchical(const WCHAR **ptr, parse_data *data, DWORD flags)
Definition: uri.c:1845
#define TRUE
Definition: types.h:120
static HRESULT canonicalize_uri(const parse_data *data, Uri *uri, DWORD flags)
Definition: uri.c:3374
INT scheme_start
Definition: uri.c:66
HRESULT hr
Definition: shlfolder.c:183
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
GLsizei const GLchar ** path
Definition: glext.h:7234
static BOOL parse_uri(parse_data *data, DWORD flags)
Definition: uri.c:2121
GLintptr offset
Definition: glext.h:5920
#define URL_DONT_UNESCAPE_EXTRA_INFO
Definition: shlwapi.h:1218
DWORD query_len
Definition: uri.c:92
static DWORD generate_raw_uri(const parse_data *data, BSTR uri, DWORD flags)
Definition: uri.c:4043
static BOOL is_drive_path(const WCHAR *str)
Definition: uri.c:270
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
INT userinfo_split
Definition: uri.c:72
DWORD host_len
Definition: uri.c:75
INT authority_start
Definition: uri.c:82
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint base
Definition: 3dtext.c:35
#define URI_DISPLAY_NO_DEFAULT_PORT_AUTH
Definition: uri.c:31
static PVOID ptr
Definition: dispmode.c:27
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static BOOL parse_path_opaque(const WCHAR **ptr, parse_data *data, DWORD flags)
Definition: uri.c:1922
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:241
#define RAW_URI_FORCE_PORT_DISP
Definition: uri.c:40
INT host_start
Definition: uri.c:74
INT userinfo_start
Definition: uri.c:70
BOOL has_port
Definition: uri.c:80
INT query_start
Definition: uri.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
DWORD port
Definition: uri.c:79
DWORD fragment_len
Definition: uri.c:95
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define RAW_URI_CONVERT_TO_DOS_PATH
Definition: uri.c:41
GLbitfield flags
Definition: glext.h:7161
#define URL_FILE_USE_PATHURL
Definition: shlwapi.h:1226
int ret
#define URL_DONT_SIMPLIFY
Definition: shlwapi.h:1214
#define COMBINE_URI_FORCE_FLAG_USE
Definition: uri.c:43
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
INT path_start
Definition: uri.c:87
DWORD userinfo_len
Definition: uri.c:71
#define S_OK
Definition: intsafe.h:59
static DWORD path_len
Definition: batch.c:31
Definition: services.c:325
static void apply_default_flags(DWORD *flags)
Definition: uri.c:397
Definition: uri.c:49
Uri_HOST_TYPE host_type
Definition: uri.c:76
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:274
WCHAR * canon_uri
Definition: uri.c:60
DWORD create_flags
Definition: sec_mgr.c:1595
static DWORD remove_dot_segments(WCHAR *path, DWORD path_len)
Definition: uri.c:631
HRESULT Uri_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
Definition: uri.c:5657
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
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:6401
DWORD path_len
Definition: uri.c:88
INT fragment_start
Definition: uri.c:94
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static const WCHAR slashW[]
Definition: devenum.c:62

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 3876 of file uri.c.

3877 {
3878  WCHAR *canon_path_a, *canon_path_b;
3879  DWORD len_a, len_b;
3880 
3881  if(!a->path_len) {
3882  *ret = !b->path_len;
3883  return S_OK;
3884  }
3885 
3886  if(!b->path_len) {
3887  *ret = FALSE;
3888  return S_OK;
3889  }
3890 
3891  /* Fast path */
3892  if(a->path_len == b->path_len && !memicmpW(a->canon_uri+a->path_start, b->canon_uri+b->path_start, a->path_len)) {
3893  *ret = TRUE;
3894  return S_OK;
3895  }
3896 
3897  len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, NULL);
3898  len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, NULL);
3899 
3900  canon_path_a = heap_alloc(len_a*sizeof(WCHAR));
3901  if(!canon_path_a)
3902  return E_OUTOFMEMORY;
3903  canon_path_b = heap_alloc(len_b*sizeof(WCHAR));
3904  if(!canon_path_b) {
3905  heap_free(canon_path_a);
3906  return E_OUTOFMEMORY;
3907  }
3908 
3909  len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, canon_path_a);
3910  len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, canon_path_b);
3911 
3912  *ret = len_a == len_b && !memicmpW(canon_path_a, canon_path_b, len_a);
3913 
3914  heap_free(canon_path_a);
3915  heap_free(canon_path_b);
3916  return S_OK;
3917 }
#define TRUE
Definition: types.h:120
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
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:2845
#define S_OK
Definition: intsafe.h:59
#define memicmpW(s1, s2, n)
Definition: unicode.h:27
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by compare_uris().

◆ compare_uris()

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

Definition at line 3924 of file uri.c.

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

Referenced by Uri_IsEqual().

◆ compute_canonicalized_length()

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

Definition at line 3333 of file uri.c.

3333  {
3334  Uri uri;
3335 
3336  memset(&uri, 0, sizeof(Uri));
3337 
3338  TRACE("(%p %x): Beginning to compute canonicalized length for URI %s\n", data, flags,
3339  debugstr_w(data->uri));
3340 
3341  if(!canonicalize_scheme(data, &uri, flags, TRUE)) {
3342  ERR("(%p %x): Failed to compute URI scheme length.\n", data, flags);
3343  return -1;
3344  }
3345 
3347  ERR("(%p %x): Failed to compute URI hierpart length.\n", data, flags);
3348  return -1;
3349  }
3350 
3351  if(!canonicalize_query(data, &uri, flags, TRUE)) {
3352  ERR("(%p %x): Failed to compute query string length.\n", data, flags);
3353  return -1;
3354  }
3355 
3357  ERR("(%p %x): Failed to compute fragment length.\n", data, flags);
3358  return -1;
3359  }
3360 
3361  TRACE("(%p %x): Finished computing canonicalized URI length. length=%d\n", data, flags, uri.canon_len);
3362 
3363  return uri.canon_len;
3364 }
#define TRUE
Definition: types.h:120
const char * uri
Definition: sec_mgr.c:1594
static BOOL canonicalize_fragment(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3239
#define debugstr_w
Definition: kernel32.h:32
static BOOL canonicalize_query(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3189
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3098
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
#define ERR(fmt,...)
Definition: debug.h:109
Definition: uri.c:49
#define memset(x, y, z)
Definition: compat.h:39
static BOOL canonicalize_scheme(const parse_data *data, Uri *uri, DWORD flags, BOOL computeOnly)
Definition: uri.c:3290

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 717 of file uri.c.

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

Referenced by canonicalize_ipv6address().

◆ compute_ipv6_comps_size()

static void compute_ipv6_comps_size ( ipv6_address address)
static

Definition at line 444 of file uri.c.

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

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 4020 of file uri.c.

4022 {
4023  const WCHAR *ptr = path;
4024 
4025  if(path_len > 3 && *ptr == '/' && is_drive_path(path+1))
4026  /* Skip over the leading / before the drive path. */
4027  ++ptr;
4028 
4029  for(; ptr < path+path_len; ++ptr) {
4030  if(*ptr == '/') {
4031  if(output)
4032  *output++ = '\\';
4033  (*output_len)++;
4034  } else {
4035  if(output)
4036  *output++ = *ptr;
4037  (*output_len)++;
4038  }
4039  }
4040 }
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLsizei const GLchar ** path
Definition: glext.h:7234
static BOOL is_drive_path(const WCHAR *str)
Definition: uri.c:270
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD path_len
Definition: batch.c:31
Definition: services.c:325

Referenced by generate_raw_uri().

◆ CreateIUriBuilder()

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

Definition at line 6354 of file uri.c.

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