Thomas Mullaly : urlmon: Implemented PARSE_PATH_FROM_URL for CoInternetParseIUri.
Alexandre Julliard
julliard at winehq.org
Fri Dec 3 09:31:37 CST 2010
Module: wine
Branch: master
Commit: 221331e72b8193ca2b13ace352a7ad41e804681d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=221331e72b8193ca2b13ace352a7ad41e804681d
Author: Thomas Mullaly <thomas.mullaly at gmail.com>
Date: Tue Nov 30 20:28:36 2010 -0500
urlmon: Implemented PARSE_PATH_FROM_URL for CoInternetParseIUri.
---
dlls/urlmon/tests/uri.c | 9 +++++-
dlls/urlmon/uri.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 706e8b5..01a0f5a 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -5941,7 +5941,14 @@ static const uri_parse_test uri_parse_tests[] = {
{"file:///c:/test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
{"zip://google.com/#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
{"zip:test#frag",0,PARSE_DOCUMENT,0,"",S_OK,FALSE},
- {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE}
+ {"testing#frag",Uri_CREATE_ALLOW_RELATIVE,PARSE_DOCUMENT,0,"",S_OK,FALSE},
+
+ /* PARSE_PATH_FROM_URL tests. */
+ {"file:///c:/test.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\test.mp3",S_OK,FALSE},
+ {"file:///c:/t<|>est.mp3",0,PARSE_PATH_FROM_URL,0,"c:\\t<|>est.mp3",S_OK,FALSE},
+ {"file:///c:/te%XX t/",0,PARSE_PATH_FROM_URL,0,"c:\\te%XX t\\",S_OK,FALSE},
+ {"file://server/test",0,PARSE_PATH_FROM_URL,0,"\\\\server\\test",S_OK,FALSE},
+ {"http://google.com/",0,PARSE_PATH_FROM_URL,0,"",E_INVALIDARG,FALSE}
};
static inline LPWSTR a2w(LPCSTR str) {
diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c
index 4247c71..b09a165 100644
--- a/dlls/urlmon/uri.c
+++ b/dlls/urlmon/uri.c
@@ -6298,6 +6298,64 @@ static HRESULT parse_document(const Uri *uri, LPWSTR output, DWORD output_len,
return S_OK;
}
+static HRESULT parse_path_from_url(const Uri *uri, LPWSTR output, DWORD output_len,
+ DWORD *result_len)
+{
+ const WCHAR *path_ptr;
+ WCHAR buffer[INTERNET_MAX_URL_LENGTH+1];
+ WCHAR *ptr;
+
+ if(uri->scheme_type != URL_SCHEME_FILE) {
+ *result_len = 0;
+ if(output_len > 0)
+ output[0] = 0;
+ return E_INVALIDARG;
+ }
+
+ ptr = buffer;
+ if(uri->host_start > -1) {
+ static const WCHAR slash_slashW[] = {'\\','\\'};
+
+ memcpy(ptr, slash_slashW, sizeof(slash_slashW));
+ ptr += sizeof(slash_slashW)/sizeof(WCHAR);
+ memcpy(ptr, uri->canon_uri+uri->host_start, uri->host_len*sizeof(WCHAR));
+ ptr += uri->host_len;
+ }
+
+ path_ptr = uri->canon_uri+uri->path_start;
+ if(uri->path_len > 3 && *path_ptr == '/' && is_drive_path(path_ptr+1))
+ /* Skip past the '/' in front of the drive path. */
+ ++path_ptr;
+
+ for(; path_ptr < uri->canon_uri+uri->path_start+uri->path_len; ++path_ptr, ++ptr) {
+ BOOL do_default_action = TRUE;
+
+ if(*path_ptr == '%') {
+ const WCHAR decoded = decode_pct_val(path_ptr);
+ if(decoded) {
+ *ptr = decoded;
+ path_ptr += 2;
+ do_default_action = FALSE;
+ }
+ } else if(*path_ptr == '/') {
+ *ptr = '\\';
+ do_default_action = FALSE;
+ }
+
+ if(do_default_action)
+ *ptr = *path_ptr;
+ }
+
+ *ptr = 0;
+
+ *result_len = ptr-buffer;
+ if(*result_len+1 > output_len)
+ return STRSAFE_E_INSUFFICIENT_BUFFER;
+
+ memcpy(output, buffer, (*result_len+1)*sizeof(WCHAR));
+ return S_OK;
+}
+
/***********************************************************************
* CoInternetParseIUri (urlmon.@)
*/
@@ -6350,6 +6408,15 @@ HRESULT WINAPI CoInternetParseIUri(IUri *pIUri, PARSEACTION ParseAction, DWORD d
}
hr = parse_document(uri, pwzResult, cchResult, pcchResult);
break;
+ case PARSE_PATH_FROM_URL:
+ if(!(uri = get_uri_obj(pIUri))) {
+ *pcchResult = 0;
+ FIXME("(%p %d %x %p %d %p %x) Unknown IUri's not supported for this action.\n",
+ pIUri, ParseAction, dwFlags, pwzResult, cchResult, pcchResult, (DWORD)dwReserved);
+ return E_NOTIMPL;
+ }
+ hr = parse_path_from_url(uri, pwzResult, cchResult, pcchResult);
+ break;
case PARSE_SECURITY_URL:
case PARSE_MIME:
case PARSE_SERVER:
More information about the wine-cvs
mailing list