Robert Shearman : wininet: Get the string for the scheme if specified only by the

Alexandre Julliard julliard at wine.codeweavers.com
Thu Mar 9 16:06:07 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 02839948d25a1cc99c5c89c9596ae3c3502631fe
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=02839948d25a1cc99c5c89c9596ae3c3502631fe

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Mar  9 15:15:45 2006 +0000

wininet: Get the string for the scheme if specified only by the
INTERNET_SCHEME enumeration in InternetCreateUrlW.

---

 dlls/wininet/internet.c   |   28 +++++++++++++++++++++++++++-
 dlls/wininet/tests/http.c |   18 ++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 7b87009..3255384 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -3712,6 +3712,17 @@ static BOOL url_uses_default_port(LPURL_
     return FALSE;
 }
 
+static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
+{
+    int index;
+    if (scheme < INTERNET_SCHEME_FIRST)
+        return NULL;
+    index = scheme - INTERNET_SCHEME_FIRST;
+    if (index >= sizeof(url_schemes)/sizeof(url_schemes[0]))
+        return NULL;
+    return (LPCWSTR)&url_schemes[index];
+}
+
 /* we can calculate using ansi strings because we're just
  * calculating string length, not size
  */
@@ -3720,7 +3731,15 @@ static BOOL calc_url_length(LPURL_COMPON
 {
     *lpdwUrlLength = 0;
 
-    *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
+    if (lpUrlComponents->lpszScheme)
+        *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
+    else
+    {
+        LPCWSTR scheme = INTERNET_GetSchemeString(lpUrlComponents->nScheme);
+        TRACE("got scheme %s\n", debugstr_w(scheme));
+        *lpdwUrlLength += strlenW(scheme);
+    }
+
     *lpdwUrlLength += strlen("://");
 
     if (lpUrlComponents->lpszUserName)
@@ -3922,6 +3941,13 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COM
         memcpy(lpszUrl, lpUrlComponents->lpszScheme, dwLen * sizeof(WCHAR));
         lpszUrl += dwLen;
     }
+    else
+    {
+        LPCWSTR scheme = INTERNET_GetSchemeString(lpUrlComponents->nScheme);
+        dwLen = strlenW(scheme);
+        memcpy(lpszUrl, scheme, dwLen * sizeof(WCHAR));
+        lpszUrl += dwLen;
+    }
 
     memcpy(lpszUrl, colonSlashW, sizeof(colonSlashW));
     lpszUrl += sizeof(colonSlashW)/sizeof(colonSlashW[0]);
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 5d25f0c..92f4c60 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -47,6 +47,7 @@
 #define CREATE_URL6 "nhttp://username:[email protected]:80/site/about"
 #define CREATE_URL7 "http://username:[email protected]:42/site/about"
 #define CREATE_URL8 "https://username:[email protected]/site/about"
+#define CREATE_URL9 "about:blank"
 
 static HANDLE hCompleteEvent;
 
@@ -1102,6 +1103,23 @@ static void InternetCreateUrlA_test(void
 	ok(!strcmp(szUrl, CREATE_URL8), "Expected %s, got %s\n", CREATE_URL8, szUrl);
 
 	HeapFree(GetProcessHeap(), 0, szUrl);
+
+	memset(&urlComp, 0, sizeof(urlComp));
+	urlComp.dwStructSize = sizeof(URL_COMPONENTS);
+	urlComp.lpszScheme = "about";
+	urlComp.dwSchemeLength = 5;
+	urlComp.lpszUrlPath = "blank";
+	urlComp.dwUrlPathLength = 5;
+	len = strlen(CREATE_URL9);
+	szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
+	ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
+	todo_wine {
+	ok(ret, "Expected success\n");
+	ok(len == strlen(CREATE_URL9), "Expected len %d, got %ld\n", strlen(CREATE_URL9), len);
+	ok(!strcmp(szUrl, CREATE_URL9), "Expected %s, got %s\n", CREATE_URL9, szUrl);
+	}
+
+	HeapFree(GetProcessHeap(), 0, szUrl);
 }
 
 static void HttpSendRequestEx_test(void)




More information about the wine-cvs mailing list