dlls/wininet/internet.c: Handle more Escape situations
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Sun May 22 12:11:39 CDT 2005
Changelog:
dlls/wininet/internet.c: CrackURL, dlls/wininet/tests/http.c
Add some escape/unescape cases and code thor that cases
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.123
diff -u -r1.123 internet.c
--- wine/dlls/wininet/internet.c 18 Apr 2005 10:30:55 -0000 1.123
+++ wine/dlls/wininet/internet.c 22 May 2005 11:14:47 -0000
@@ -1041,6 +1041,7 @@
LPWSTR lpwszComponent, DWORD dwwComponentLen,
LPCSTR lpszStart, LPCWSTR lpwszStart)
{
+ TRACE("%p %p %p %ld %p %p\n", lppszComponent, dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
if (*dwComponentLen != 0)
{
DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
@@ -1080,6 +1081,7 @@
URL_COMPONENTSW UCW;
WCHAR* lpwszUrl;
+ TRACE("(%s %lu %lx %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
if(dwUrlLength<=0)
dwUrlLength=-1;
nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
@@ -1093,17 +1095,17 @@
memset(&UCW,0,sizeof(UCW));
if(lpUrlComponents->dwHostNameLength!=0)
- UCW.dwHostNameLength=1;
+ UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
if(lpUrlComponents->dwUserNameLength!=0)
- UCW.dwUserNameLength=1;
+ UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength ;
if(lpUrlComponents->dwPasswordLength!=0)
- UCW.dwPasswordLength=1;
+ UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
if(lpUrlComponents->dwUrlPathLength!=0)
- UCW.dwUrlPathLength=1;
+ UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
if(lpUrlComponents->dwSchemeLength!=0)
- UCW.dwSchemeLength=1;
+ UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
if(lpUrlComponents->dwExtraInfoLength!=0)
- UCW.dwExtraInfoLength=1;
+ UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
{
HeapFree(GetProcessHeap(), 0, lpwszUrl);
@@ -1163,7 +1165,7 @@
static const WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
static const WCHAR lpszRes[]={'r','e','s',0};
WCHAR* tempBuffer=NULL;
- TRACE("\n");
+ TRACE("%s %ld\n",debugstr_wn(lpszScheme, nMaxCmp), nMaxCmp);
if(lpszScheme==NULL)
return INTERNET_SCHEME_UNKNOWN;
@@ -1236,7 +1238,7 @@
/***********************************************************************
* InternetCrackUrlW (WININET.@)
*/
-BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
+BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWORD dwFlags,
LPURL_COMPONENTSW lpUC)
{
/*
@@ -1246,15 +1248,26 @@
*/
LPCWSTR lpszParam = NULL;
BOOL bIsAbsolute = FALSE;
- LPCWSTR lpszap = lpszUrl;
+ LPCWSTR lpszap, lpszUrl = lpszUrl_orig;
LPCWSTR lpszcp = NULL;
+ LPWSTR lpszUrl_decode = NULL;
+ DWORD dwUrlLength = dwUrlLength_orig;
const WCHAR lpszSeparators[3]={';','?',0};
const WCHAR lpszSlash[2]={'/',0};
if(dwUrlLength==0)
dwUrlLength=strlenW(lpszUrl);
TRACE("(%s %lu %lx %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
-
+ if (dwFlags & ICU_DECODE)
+ {
+ lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) );
+ if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags))
+ {
+ lpszUrl = lpszUrl_decode;
+ }
+ }
+ lpszap = lpszUrl;
+
/* Determine if the URI is absolute. */
while (*lpszap != '\0')
{
@@ -1442,7 +1455,6 @@
else
len = dwUrlLength-(lpszcp-lpszUrl);
}
-
SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
lpszcp, len);
}
@@ -1451,11 +1463,14 @@
lpUC->dwUrlPathLength = 0;
}
- TRACE("%s: host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
+ TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
+ debugstr_wn(lpUC->lpszScheme,lpUC->dwSchemeLength),
debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
+ if (lpszUrl_decode)
+ HeapFree(GetProcessHeap(), 0, lpszUrl_decode );
return TRUE;
}
@@ -1490,15 +1505,27 @@
LPDWORD lpdwBufferLength, DWORD dwFlags)
{
HRESULT hr;
- TRACE("%s %p %p %08lx\n",debugstr_a(lpszUrl), lpszBuffer,
- lpdwBufferLength, dwFlags);
+ DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
+ if(dwFlags & ICU_DECODE)
+ {
+ dwURLFlags |= URL_UNESCAPE;
+ dwFlags &= ~ICU_DECODE;
+ }
+
+ if(dwFlags & ICU_ESCAPE)
+ {
+ dwURLFlags |= URL_UNESCAPE;
+ dwFlags &= ~ICU_ESCAPE;
+ }
+ if(dwFlags)
+ FIXME("Unhandled flags 0x%08lx\n", dwFlags);
+ TRACE("%s %p %p %08lx\n", debugstr_a(lpszUrl), lpszBuffer,
+ lpdwBufferLength, dwURLFlags);
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
dwFlags ^= ICU_NO_ENCODE;
- dwFlags |= 0x80000000; /* Don't know what this means */
-
- hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
+ hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
return (hr == S_OK) ? TRUE : FALSE;
}
@@ -1517,15 +1544,27 @@
LPDWORD lpdwBufferLength, DWORD dwFlags)
{
HRESULT hr;
+ DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
+ if(dwFlags & ICU_DECODE)
+ {
+ dwURLFlags |= URL_UNESCAPE;
+ dwFlags &= ~ICU_DECODE;
+ }
+
+ if(dwFlags & ICU_ESCAPE)
+ {
+ dwURLFlags |= URL_UNESCAPE;
+ dwFlags &= ~ICU_ESCAPE;
+ }
+ if(dwFlags)
+ FIXME("Unhandled flags 0x%08lx\n", dwFlags);
TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
- lpdwBufferLength, dwFlags);
+ lpdwBufferLength, dwURLFlags);
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
dwFlags ^= ICU_NO_ENCODE;
- dwFlags |= 0x80000000; /* Don't know what this means */
-
- hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
+ hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
return (hr == S_OK) ? TRUE : FALSE;
}
Index: wine/dlls/wininet/tests/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/tests/http.c,v
retrieving revision 1.22
diff -u -r1.22 http.c
--- wine/dlls/wininet/tests/http.c 11 Apr 2005 16:10:50 -0000 1.22
+++ wine/dlls/wininet/tests/http.c 22 May 2005 11:14:48 -0000
@@ -15,6 +15,7 @@
#define TEST_URL2_PATH "/myscript.php"
#define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
#define TEST_URL2_EXTRA "?arg=1"
+#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
int goon = 0;
@@ -310,7 +311,22 @@
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %ld\n", 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);
-
+ /*3. Check for %20 */
+ ZeroMemory(&urlComponents, sizeof(urlComponents));
+ urlComponents.dwStructSize = sizeof(urlComponents);
+ urlComponents.lpszScheme = protocol;
+ urlComponents.dwSchemeLength = 32;
+ urlComponents.lpszHostName = hostName;
+ urlComponents.dwHostNameLength = 1024;
+ urlComponents.lpszUserName = userName;
+ urlComponents.dwUserNameLength = 1024;
+ urlComponents.lpszPassword = password;
+ urlComponents.dwPasswordLength = 1024;
+ urlComponents.lpszUrlPath = path;
+ urlComponents.dwUrlPathLength = 2048;
+ urlComponents.lpszExtraInfo = extra;
+ ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE 0x%lx\n",GetLastError());
+ fprintf(stderr,"BON:%*s\n", (int)urlComponents.dwUrlPathLength, urlComponents.lpszUrlPath);
}
More information about the wine-patches
mailing list