Robert Shearman : wininet: InternetCrackUrl should set nPort to the default port if not specified.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 13 08:46:41 CST 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Sat Mar 11 18:09:21 2006 +0000

wininet: InternetCrackUrl should set nPort to the default port if not specified.

---

 dlls/wininet/internet.c   |   19 +++++++++++++++++--
 dlls/wininet/tests/http.c |    2 ++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 503c271..db6371b 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1467,8 +1467,23 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
                                               lpszHost, lpszPort - lpszHost);
                         if (lpszPort != lpszNetLoc)
                             lpUC->nPort = atoiW(++lpszPort);
-                        else
-                            lpUC->nPort = 0;
+                        else switch (lpUC->nScheme)
+                        {
+                        case INTERNET_SCHEME_HTTP:
+                            lpUC->nPort = INTERNET_DEFAULT_HTTP_PORT;
+                            break;
+                        case INTERNET_SCHEME_HTTPS:
+                            lpUC->nPort = INTERNET_DEFAULT_HTTPS_PORT;
+                            break;
+                        case INTERNET_SCHEME_FTP:
+                            lpUC->nPort = INTERNET_DEFAULT_FTP_PORT;
+                            break;
+                        case INTERNET_SCHEME_GOPHER:
+                            lpUC->nPort = INTERNET_DEFAULT_GOPHER_PORT;
+                            break;
+                        default:
+                            lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
+                        }
                     }
                 }
             }
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 3f512cf..4b6a2ad 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -598,6 +598,8 @@ static void InternetCrackUrl_test(void)
   ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
   ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %ld, but is %ld\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
   ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
+  ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
+  ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
 
   /*3. Check for %20 */
   copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);




More information about the wine-cvs mailing list