ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2014
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
16 participants
413 discussions
Start a n
N
ew thread
[akhaldi] 64280: [README.WINE] * Mark iexplore as synced with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:42:43 2014 New Revision: 64280 URL:
http://svn.reactos.org/svn/reactos?rev=64280&view=rev
Log: [README.WINE] * Mark iexplore as synced with Wine 1.7.27. CORE-8540 Modified: trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Sep 25 15:42:43 2014 @@ -237,7 +237,7 @@ reactos/base/applications/cmdutils/xcopy # Synced to Wine-1.7.1 reactos/base/applications/games/winmine # Forked at Wine-1_3_5 reactos/base/applications/extrac32 # Synced to Wine-1.7.1 -reactos/base/applications/iexplore # Synced to Wine-1.7.1 +reactos/base/applications/iexplore # Synced to Wine-1.7.27 reactos/base/applications/notepad # Forked at Wine-20041201 reactos/base/applications/regedit # Out of sync reactos/base/applications/winhlp32 # Synced to Wine-1.5.26
10 years, 3 months
1
0
0
0
[akhaldi] 64279: [URLMON_WINETEST] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:40:15 2014 New Revision: 64279 URL:
http://svn.reactos.org/svn/reactos?rev=64279&view=rev
Log: [URLMON_WINETEST] * Sync with Wine 1.7.27. CORE-8540 Modified: trunk/rostests/winetests/urlmon/misc.c trunk/rostests/winetests/urlmon/uri.c trunk/rostests/winetests/urlmon/url.c Modified: trunk/rostests/winetests/urlmon/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/misc.c?r…
============================================================================== --- trunk/rostests/winetests/urlmon/misc.c [iso-8859-1] (original) +++ trunk/rostests/winetests/urlmon/misc.c [iso-8859-1] Thu Sep 25 15:40:15 2014 @@ -581,6 +581,8 @@ static BYTE data94[] = {'<','h','t','m','l','>','<','?','x','m','l',' ',' '}; static BYTE data95[] = {'{','\\','r','t','f','<','?','x','m','l',' ',' '}; static BYTE data96[] = {'<','?','x','m','l',' '}; +static BYTE data97[] = "<body"; +static BYTE data98[] = "blah<BoDyblahblah"; static const struct { BYTE *data; @@ -687,6 +689,8 @@ {data94, sizeof(data94), "text/html", "text/plain"}, {data95, sizeof(data95), "text/xml", "text/richtext"}, {data96, sizeof(data96), "text/plain"}, + {data97, sizeof(data97), "text/html", "text/plain"}, + {data98, sizeof(data98), "text/html", "text/plain"}, {data1, sizeof(data1), "text/plain", NULL, NULL, "res://mshtml.dll/blank.htm"}, {NULL, 0, "text/html", NULL, NULL, "res://mshtml.dll/blank.htm"}, {data1, sizeof(data1), "text/plain", NULL, NULL, "res://mshtml.dll/blank.htm", "application/octet-stream"}, Modified: trunk/rostests/winetests/urlmon/uri.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/uri.c?re…
============================================================================== --- trunk/rostests/winetests/urlmon/uri.c [iso-8859-1] (original) +++ trunk/rostests/winetests/urlmon/uri.c [iso-8859-1] Thu Sep 25 15:40:15 2014 @@ -392,6 +392,31 @@ {URLZONE_INVALID,E_NOTIMPL,FALSE} } }, + { "file:///z:/test dir/README.txt#hash part", 0, S_OK, FALSE, + { + {"file:///z:/test%20dir/README.txt#hash%20part",S_OK}, + {"",S_FALSE}, + {"file:///z:/test%20dir/README.txt#hash%20part",S_OK}, + {"",S_FALSE}, + {".txt#hash%20part",S_OK}, + {"",S_FALSE}, + {"",S_FALSE}, + {"",S_FALSE}, + {"/z:/test%20dir/README.txt#hash%20part",S_OK}, + {"/z:/test%20dir/README.txt#hash%20part",S_OK}, + {"",S_FALSE}, + {"file:///z:/test dir/README.txt#hash part",S_OK}, + {"file",S_OK}, + {"",S_FALSE}, + {"",S_FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, { "urn:nothing:should:happen here", 0, S_OK, FALSE, { {"urn:nothing:should:happen here",S_OK,FALSE}, @@ -589,6 +614,81 @@ }, { {Uri_HOST_DNS,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "C:/test/test.mp3#fragment|part", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_FILE_USE_DOS_PATH|Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE, + { + {"file://C:\\test\\test.mp3#fragment|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file://C:\\test\\test.mp3#fragment|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".mp3#fragment|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"C:\\test\\test.mp3#fragment|part",S_OK,FALSE}, + {"C:\\test\\test.mp3#fragment|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"C:/test/test.mp3#fragment|part",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "C:/test/test.mp3?query|part", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_FILE_USE_DOS_PATH|Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE, + { + {"file://C:\\test\\test.mp3?query|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file://C:\\test\\test.mp3?query|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".mp3",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"C:\\test\\test.mp3",S_OK,FALSE}, + {"C:\\test\\test.mp3?query|part",S_OK,FALSE}, + {"?query|part",S_OK,FALSE}, + {"C:/test/test.mp3?query|part",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "C:/test/test.mp3?query|part#hash|part", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME|Uri_CREATE_FILE_USE_DOS_PATH|Uri_CREATE_NO_DECODE_EXTRA_INFO, S_OK, FALSE, + { + {"file://C:\\test\\test.mp3?query|part#hash|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file://C:\\test\\test.mp3?query|part#hash|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".mp3",S_OK,FALSE}, + {"#hash|part",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"C:\\test\\test.mp3",S_OK,FALSE}, + {"C:\\test\\test.mp3?query|part",S_OK,FALSE}, + {"?query|part",S_OK,FALSE}, + {"C:/test/test.mp3?query|part#hash|part",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, {0,S_FALSE,FALSE}, {URL_SCHEME_FILE,S_OK,FALSE}, {URLZONE_INVALID,E_NOTIMPL,FALSE} @@ -4578,7 +4678,107 @@ {URL_SCHEME_MAILTO,S_OK}, {URLZONE_INVALID,E_NOTIMPL} } - } + }, + { "c:\\test file.html", Uri_CREATE_FILE_USE_DOS_PATH|Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE, + { + {"file://c:\\test file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file://c:\\test file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test file.html",S_OK,FALSE}, + {"c:\\test file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test file.html",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "c:\\test%20file.html", Uri_CREATE_FILE_USE_DOS_PATH|Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE, + { + {"file://c:\\test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file://c:\\test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test%20file.html",S_OK,FALSE}, + {"c:\\test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test%20file.html",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "c:\\test file.html", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE, + { + {"file:///c:/test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file:///c:/test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"/c:/test%20file.html",S_OK,FALSE}, + {"/c:/test%20file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test file.html",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + }, + { "c:\\test%20file.html", Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, S_OK, FALSE, + { + {"file:///c:/test%2520file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"file:///c:/test%2520file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {".html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE}, + {"/c:/test%2520file.html",S_OK,FALSE}, + {"/c:/test%2520file.html",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"c:\\test%20file.html",S_OK,FALSE}, + {"file",S_OK,FALSE}, + {"",S_FALSE,FALSE}, + {"",S_FALSE,FALSE} + }, + { + {Uri_HOST_UNKNOWN,S_OK,FALSE}, + {0,S_FALSE,FALSE}, + {URL_SCHEME_FILE,S_OK,FALSE}, + {URLZONE_INVALID,E_NOTIMPL,FALSE} + } + } }; typedef struct _invalid_uri { @@ -4590,7 +4790,7 @@ static const invalid_uri invalid_uri_tests[] = { /* Has to have a scheme name. */ {"://www.winehq.org",0,FALSE}, - /* Window's doesn't like URI's which are implicitly file paths without the + /* Windows doesn't like URIs which are implicitly file paths without the * ALLOW_IMPLICIT_FILE_SCHEME flag set. */ {"C:/test/test.mp3",0,FALSE}, @@ -11044,6 +11244,14 @@ "file:///c:/dir/file.txt", "file:///c:/dir/file.txt", "file:///c:/dir/file.txt", + }, + { + "c:\\dir\\file.txt#frag|part",Uri_CREATE_ALLOW_IMPLICIT_FILE_SCHEME, + NULL,0, + "file://c:\\dir\\file.txt#frag|part", + "file:///c:/dir/file.txt#frag%7Cpart", + "file:///c:/dir/file.txt#frag%7Cpart", + "file:///c:/dir/file.txt#frag%7Cpart", } }; Modified: trunk/rostests/winetests/urlmon/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/url.c?re…
============================================================================== --- trunk/rostests/winetests/urlmon/url.c [iso-8859-1] (original) +++ trunk/rostests/winetests/urlmon/url.c [iso-8859-1] Thu Sep 25 15:40:15 2014 @@ -4091,4 +4091,3 @@ CloseHandle(complete_event2); CoUninitialize(); } -
10 years, 3 months
1
0
0
0
[akhaldi] 64278: [URLMON] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:39:47 2014 New Revision: 64278 URL:
http://svn.reactos.org/svn/reactos?rev=64278&view=rev
Log: [URLMON] * Sync with Wine 1.7.27. CORE-8540 Modified: trunk/reactos/dll/win32/urlmon/bindprot.c trunk/reactos/dll/win32/urlmon/mimefilter.c trunk/reactos/dll/win32/urlmon/sec_mgr.c trunk/reactos/dll/win32/urlmon/uri.c trunk/reactos/dll/win32/urlmon/urlmon_main.c trunk/reactos/dll/win32/urlmon/urlmon_main.h trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/urlmon/bindprot.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/bindprot.…
============================================================================== --- trunk/reactos/dll/win32/urlmon/bindprot.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/bindprot.c [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -80,14 +80,49 @@ return DefWindowProcW(hwnd, msg, wParam, lParam); } +#ifndef __REACTOS__ + +static const WCHAR wszURLMonikerNotificationWindow[] = + {'U','R','L',' ','M','o','n','i','k','e','r',' ', + 'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0}; + +static ATOM notif_wnd_class; + +static BOOL WINAPI register_notif_wnd_class(INIT_ONCE *once, void *param, void **context) +{ + static WNDCLASSEXW wndclass = { + sizeof(wndclass), 0, notif_wnd_proc, 0, 0, + NULL, NULL, NULL, NULL, NULL, + wszURLMonikerNotificationWindow, NULL + }; + + wndclass.hInstance = hProxyDll; + notif_wnd_class = RegisterClassExW(&wndclass); + return TRUE; +} + +void unregister_notif_wnd_class(void) +{ + if(notif_wnd_class) + UnregisterClassW(MAKEINTRESOURCEW(notif_wnd_class), hProxyDll); +} + +#endif /* !__REACTOS__ */ + HWND get_notif_hwnd(void) { +#ifdef __REACTOS__ static ATOM wnd_class = 0; +#endif tls_data_t *tls_data; +#ifdef __REACTOS__ static const WCHAR wszURLMonikerNotificationWindow[] = {'U','R','L',' ','M','o','n','i','k','e','r',' ', 'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0}; +#else + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; +#endif tls_data = get_tls_data(); if(!tls_data) @@ -98,6 +133,11 @@ return tls_data->notif_hwnd; } +#ifndef __REACTOS__ + InitOnceExecuteOnce(&init_once, register_notif_wnd_class, NULL, NULL); + if(!notif_wnd_class) + return NULL; +#else if(!wnd_class) { static WNDCLASSEXW wndclass = { sizeof(wndclass), 0, @@ -113,8 +153,13 @@ if (!wnd_class && GetLastError() == ERROR_CLASS_ALREADY_EXISTS) wnd_class = 1; } - +#endif + +#ifndef __REACTOS__ + tls_data->notif_hwnd = CreateWindowExW(0, MAKEINTRESOURCEW(notif_wnd_class), +#else tls_data->notif_hwnd = CreateWindowExW(0, wszURLMonikerNotificationWindow, +#endif wszURLMonikerNotificationWindow, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hProxyDll, NULL); if(tls_data->notif_hwnd) @@ -685,6 +730,9 @@ if(!This->reported_result) return E_FAIL; + /* This may get released in Terminate call. */ + IInternetProtocolEx_AddRef(&This->IInternetProtocolEx_iface); + IInternetProtocol_Terminate(This->protocol, 0); set_binding_sink(This, NULL, NULL); @@ -694,6 +742,7 @@ This->bind_info = NULL; } + IInternetProtocolEx_Release(&This->IInternetProtocolEx_iface); return S_OK; } Modified: trunk/reactos/dll/win32/urlmon/mimefilter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/mimefilte…
============================================================================== --- trunk/reactos/dll/win32/urlmon/mimefilter.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/mimefilter.c [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -277,7 +277,12 @@ && (b[1] == 'h' || b[1] == 'H') && (b[2] == 'e' || b[2] == 'E') && (b[3] == 'a' || b[3] == 'A') - && (b[4] == 'd' || b[4] == 'D'))) return TRUE; + && (b[4] == 'd' || b[4] == 'D')) + || (b[0] == '<' + && (b[1] == 'b' || b[1] == 'B') + && (b[2] == 'o' || b[2] == 'O') + && (b[3] == 'd' || b[3] == 'D') + && (b[4] == 'y' || b[4] == 'Y'))) return TRUE; return FALSE; } Modified: trunk/reactos/dll/win32/urlmon/sec_mgr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/sec_mgr.c…
============================================================================== --- trunk/reactos/dll/win32/urlmon/sec_mgr.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/sec_mgr.c [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -230,11 +230,9 @@ * * Doesn't match the pattern. */ - if(str_len > pattern_len) { - if(str[str_len-pattern_len-1] == '.' && !strcmpiW(str+(str_len-pattern_len), pattern)) { - matches = TRUE; - *matched = str+(str_len-pattern_len); - } + if(str[str_len-pattern_len-1] == '.' && !strcmpiW(str+(str_len-pattern_len), pattern)) { + matches = TRUE; + *matched = str+(str_len-pattern_len); } } else { /* The pattern doesn't have an implicit wildcard, or an explicit wildcard, @@ -2066,7 +2064,7 @@ /******************************************************************** * IsInternetESCEnabledLocal (URLMON.108) * - * Undocumented, returns if IE is running in Enhanced Security Configuration. + * Undocumented, returns TRUE if IE is running in Enhanced Security Configuration. */ BOOL WINAPI IsInternetESCEnabledLocal(void) { Modified: trunk/reactos/dll/win32/urlmon/uri.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/uri.c?rev…
============================================================================== --- trunk/reactos/dll/win32/urlmon/uri.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/uri.c [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -340,8 +340,8 @@ (val >= '0' && val <= '9')); } -static inline BOOL is_path_delim(WCHAR val) { - return (!val || val == '#' || val == '?'); +static inline BOOL is_path_delim(URL_SCHEME scheme, WCHAR val) { + return (!val || (val == '#' && scheme != URL_SCHEME_FILE) || val == '?'); } static inline BOOL is_slash(WCHAR c) @@ -1834,7 +1834,7 @@ static const WCHAR slash[] = {'/',0}; const BOOL is_file = data->scheme_type == URL_SCHEME_FILE; - if(is_path_delim(**ptr)) { + if(is_path_delim(data->scheme_type, **ptr)) { if(data->scheme_type == URL_SCHEME_WILDCARD && !data->must_have_path) { data->path = NULL; data->path_len = 0; @@ -1844,7 +1844,7 @@ data->path_len = 1; } } else { - while(!is_path_delim(**ptr)) { + while(!is_path_delim(data->scheme_type, **ptr)) { if(**ptr == '%' && data->scheme_type != URL_SCHEME_UNKNOWN && !is_file) { if(!check_pct_encoded(ptr)) { *ptr = start; @@ -1919,7 +1919,7 @@ else data->path = *ptr; - while(!is_path_delim(**ptr)) { + while(!is_path_delim(data->scheme_type, **ptr)) { if(**ptr == '%' && known_scheme) { if(!check_pct_encoded(ptr)) { *ptr = data->path; @@ -2830,7 +2830,7 @@ * file:///c:/test%test -> file:///c:/test%25test */ static DWORD canonicalize_path_hierarchical(const WCHAR *path, DWORD path_len, URL_SCHEME scheme_type, BOOL has_host, DWORD flags, - WCHAR *ret_path) { + BOOL is_implicit_scheme, WCHAR *ret_path) { const BOOL known_scheme = scheme_type != URL_SCHEME_UNKNOWN; const BOOL is_file = scheme_type == URL_SCHEME_FILE; const BOOL is_res = scheme_type == URL_SCHEME_RES; @@ -2896,7 +2896,7 @@ len += 3; do_default_action = FALSE; } else if((is_unreserved(val) && known_scheme) || - (is_file && (is_unreserved(val) || is_reserved(val) || + (is_file && !is_implicit_scheme && (is_unreserved(val) || is_reserved(val) || (val && flags&Uri_CREATE_FILE_USE_DOS_PATH && !is_forbidden_dos_path_char(val))))) { if(ret_path) ret_path[len] = val; @@ -2921,7 +2921,7 @@ } } else if(known_scheme && !is_res && !is_unreserved(*ptr) && !is_reserved(*ptr) && (!(flags & Uri_CREATE_NO_ENCODE_FORBIDDEN_CHARACTERS) || is_file)) { - if(!(is_file && (flags & Uri_CREATE_FILE_USE_DOS_PATH))) { + if(!is_file || !(flags & Uri_CREATE_FILE_USE_DOS_PATH)) { /* Escape the forbidden character. */ if(ret_path) pct_encode_val(*ptr, ret_path+len); @@ -3114,7 +3114,7 @@ if(!computeOnly) uri->path_start = uri->canon_len; uri->path_len = canonicalize_path_hierarchical(data->path, data->path_len, data->scheme_type, data->host_len != 0, - flags, computeOnly ? NULL : uri->canon_uri+uri->canon_len); + flags, data->has_implicit_scheme, computeOnly ? NULL : uri->canon_uri+uri->canon_len); uri->canon_len += uri->path_len; if(!computeOnly && !uri->path_len) uri->path_start = -1; @@ -3881,8 +3881,8 @@ return S_OK; } - len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, NULL); - len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, NULL); + len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, NULL); + len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, NULL); canon_path_a = heap_alloc(len_a*sizeof(WCHAR)); if(!canon_path_a) @@ -3893,8 +3893,8 @@ return E_OUTOFMEMORY; } - len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, canon_path_a); - len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, canon_path_b); + len_a = canonicalize_path_hierarchical(a->canon_uri+a->path_start, a->path_len, a->scheme_type, FALSE, 0, FALSE, canon_path_a); + len_b = canonicalize_path_hierarchical(b->canon_uri+b->path_start, b->path_len, b->scheme_type, FALSE, 0, FALSE, canon_path_b); *ret = len_a == len_b && !memicmpW(canon_path_a, canon_path_b, len_a); Modified: trunk/reactos/dll/win32/urlmon/urlmon_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/urlmon_ma…
============================================================================== --- trunk/reactos/dll/win32/urlmon/urlmon_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/urlmon_main.c [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -127,6 +127,9 @@ free_session(); free_tls_list(); +#ifndef __REACTOS__ + unregister_notif_wnd_class(); +#endif } /*********************************************************************** Modified: trunk/reactos/dll/win32/urlmon/urlmon_main.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/urlmon/urlmon_ma…
============================================================================== --- trunk/reactos/dll/win32/urlmon/urlmon_main.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/urlmon/urlmon_main.h [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -236,6 +236,9 @@ tls_data_t *get_tls_data(void) DECLSPEC_HIDDEN; +#ifndef __REACTOS__ +void unregister_notif_wnd_class(void) DECLSPEC_HIDDEN; +#endif HWND get_notif_hwnd(void) DECLSPEC_HIDDEN; void release_notif_hwnd(HWND) DECLSPEC_HIDDEN; Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Sep 25 15:39:47 2014 @@ -198,7 +198,7 @@ reactos/dll/win32/unicows # Synced to Wine-1.3.32 (Win9x only, why do we need this?!) reactos/dll/win32/updspapi # Synced to Wine-1.7.17 reactos/dll/win32/url # Synced to Wine-1.7.17 -reactos/dll/win32/urlmon # Synced to Wine-1.7.17 +reactos/dll/win32/urlmon # Synced to Wine-1.7.27 reactos/dll/win32/usp10 # Synced to Wine-1.7.17 reactos/dll/win32/uxtheme # Forked reactos/dll/win32/vbscript # Synced to Wine-1.7.17
10 years, 3 months
1
0
0
0
[akhaldi] 64277: [WININET_WINETEST] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:31:51 2014 New Revision: 64277 URL:
http://svn.reactos.org/svn/reactos?rev=64277&view=rev
Log: [WININET_WINETEST] * Sync with Wine 1.7.27. CORE-8540 Modified: trunk/rostests/winetests/wininet/http.c trunk/rostests/winetests/wininet/internet.c trunk/rostests/winetests/wininet/url.c trunk/rostests/winetests/wininet/urlcache.c Modified: trunk/rostests/winetests/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?…
============================================================================== --- trunk/rostests/winetests/wininet/http.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/http.c [iso-8859-1] Thu Sep 25 15:31:51 2014 @@ -37,6 +37,12 @@ #include <wine/test.h> +/* Undocumented security flags */ +#define _SECURITY_FLAG_CERT_REV_FAILED 0x00800000 +#define _SECURITY_FLAG_CERT_INVALID_CA 0x01000000 +#define _SECURITY_FLAG_CERT_INVALID_CN 0x02000000 +#define _SECURITY_FLAG_CERT_INVALID_DATE 0x04000000 + #define TEST_URL "
http://test.winehq.org/tests/hello.html
" static BOOL first_connection_to_test_url = TRUE; @@ -78,7 +84,7 @@ status < MAX_INTERNET_STATUS && status_string[status] ? \ status_string[status] : "unknown"); \ if (expect[status]) expect[status]--; \ - else optional[status]--; \ + else if(optional[status]) optional[status]--; \ } \ notified[status]++; \ }while(0) @@ -144,10 +150,10 @@ TESTF_REDIRECT }, { - "
http://www.codeweavers.com/
", - "
http://www.codeweavers.com/
", - "
www.codeweavers.com
", - "", + "
http://test.winehq.org/tests/gzip.php
", + "
http://test.winehq.org/tests/gzip.php
", + "
test.winehq.org
", + "/tests/gzip.php", "Accept-Encoding: gzip, deflate", TESTF_COMPRESSED }, @@ -470,7 +476,8 @@ char *post_data = NULL; BOOL res, on_async = TRUE; CHAR buffer[4000]; - DWORD length, exlen = 0, post_len = 0; + WCHAR wbuffer[4000]; + DWORD length, length2, index, exlen = 0, post_len = 0; const char *types[2] = { "*", NULL }; HINTERNET hi, hic = 0, hor = 0; @@ -631,21 +638,82 @@ ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed with error %d\n", GetLastError()); length = sizeof(buffer)-1; + memset(buffer, 0x77, sizeof(buffer)); res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length,0x0); ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError()); - buffer[length]=0; + /* show that the function writes data past the length returned */ + ok(buffer[length-2], "Expected any header character, got 0x00\n"); + ok(!buffer[length-1], "Expected 0x00, got %02X\n", buffer[length-1]); + ok(!buffer[length], "Expected 0x00, got %02X\n", buffer[length]); + ok(buffer[length+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length+1]); + + length2 = length; + res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0); + ok(!res, "Expected 0x00, got %d\n", res); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError()); + ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2); + /* the in length of the buffer must be +1 but the length returned does not count this */ + length2 = length+1; + memset(buffer, 0x77, sizeof(buffer)); + res = HttpQueryInfoA(hor,HTTP_QUERY_RAW_HEADERS,buffer,&length2,0x0); + ok(res, "HttpQueryInfoA(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError()); + ok(buffer[length2] == 0x00, "Expected 0x00, got %02X\n", buffer[length2]); + ok(buffer[length2+1] == 0x77, "Expected 0x77, got %02X\n", buffer[length2+1]); + ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length); + + length = sizeof(wbuffer)-sizeof(WCHAR); + memset(wbuffer, 0x77, sizeof(wbuffer)); + res = HttpQueryInfoW(hor, HTTP_QUERY_RAW_HEADERS, wbuffer, &length, 0x0); + ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError()); + ok(length % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length); + length /= sizeof(WCHAR); + /* show that the function writes data past the length returned */ + ok(wbuffer[length-2], "Expected any header character, got 0x0000\n"); + ok(!wbuffer[length-1], "Expected 0x0000, got %04X\n", wbuffer[length-1]); + ok(!wbuffer[length], "Expected 0x0000, got %04X\n", wbuffer[length]); + ok(wbuffer[length+1] == 0x7777 || broken(wbuffer[length+1] != 0x7777), + "Expected 0x7777, got %04X\n", wbuffer[length+1]); + + length2 = length*sizeof(WCHAR); + res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0); + ok(!res, "Expected 0x00, got %d\n", res); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError()); + ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2); + length2 /= sizeof(WCHAR); + ok(length2 == length+1, "Expected %d, got %d\n", length+1, length2); + /* the in length of the buffer must be +1 but the length returned does not count this */ + length2 = (length+1)*sizeof(WCHAR); + memset(wbuffer, 0x77, sizeof(wbuffer)); + res = HttpQueryInfoW(hor,HTTP_QUERY_RAW_HEADERS,wbuffer,&length2,0x0); + ok(res, "HttpQueryInfoW(HTTP_QUERY_RAW_HEADERS) failed with error %d\n", GetLastError()); + ok(length2 % sizeof(WCHAR) == 0, "Expected that length is a multiple of sizeof(WCHAR), got %d.\n", length2); + length2 /= sizeof(WCHAR); + ok(!wbuffer[length2], "Expected 0x0000, got %04X\n", wbuffer[length2]); + ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]); + ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length); length = sizeof(buffer); res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length); ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer); + index = 0; + length = 0; + SetLastError(0xdeadbeef); + ok(HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,NULL,&length,&index) == FALSE,"Query worked\n"); + if(test->flags & TESTF_COMPRESSED) + ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, + "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", GetLastError()); + ok(index == 0, "Index was incremented\n"); + + index = 0; length = 16; - res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,0x0); + res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_LENGTH,&buffer,&length,&index); trace("Option HTTP_QUERY_CONTENT_LENGTH -> %i %s (%u)\n",res,buffer,GetLastError()); if(test->flags & TESTF_COMPRESSED) ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %x (%u)\n", res, GetLastError()); + ok(!res || index == 1, "Index was not incremented although result is %x (index = %u)\n", res, index); length = 100; res = HttpQueryInfoA(hor,HTTP_QUERY_CONTENT_TYPE,buffer,&length,0x0); @@ -671,8 +739,16 @@ { if (flags & INTERNET_FLAG_ASYNC) SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + + /* IE11 calls those in InternetQueryDataAvailable call. */ + SET_OPTIONAL(INTERNET_STATUS_RECEIVING_RESPONSE); + SET_OPTIONAL(INTERNET_STATUS_RESPONSE_RECEIVED); + length = 0; res = InternetQueryDataAvailable(hor,&length,0x0,0x0); + + CLEAR_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + if (flags & INTERNET_FLAG_ASYNC) { if (res) @@ -693,6 +769,7 @@ exlen = length; ok(exlen, "length = 0\n"); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); ok(req_error, "req_error = 0\n"); continue; }else { @@ -701,6 +778,8 @@ }else { ok(res, "InternetQueryDataAvailable failed: %u\n", GetLastError()); } + CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); + trace("LENGTH %d\n", length); if(test->flags & TESTF_CHUNKED) ok(length <= 8192, "length = %d, expected <= 8192\n", length); @@ -1142,11 +1221,11 @@ hSession = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); ok( hSession != NULL ,"Unable to open Internet session\n"); - hConnect = InternetConnectA(hSession, "
crossover.codeweavers.com
", + hConnect = InternetConnectA(hSession, "
test.winehq.org
", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); - ok( hConnect != NULL, "Unable to connect to
http://crossover.codeweavers.com\n
"); - hRequest = HttpOpenRequestA(hConnect, "POST", "/posttest.php", + ok( hConnect != NULL, "Unable to connect to
http://test.winehq.org\n
"); + hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) { @@ -1558,11 +1637,11 @@ hSession = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); ok( hSession != NULL ,"Unable to open Internet session\n"); - hConnect = InternetConnectA(hSession, "
crossover.codeweavers.com
", + hConnect = InternetConnectA(hSession, "
test.winehq.org
", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); - ok( hConnect != NULL, "Unable to connect to
http://crossover.codeweavers.com\n
"); - hRequest = HttpOpenRequestA(hConnect, "POST", "/posttest.php", + ok( hConnect != NULL, "Unable to connect to
http://test.winehq.org\n
"); + hRequest = HttpOpenRequestA(hConnect, "POST", "/tests/post.php", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); if (!hRequest && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED) { @@ -1599,6 +1678,8 @@ strcpy(buffer,"Warning"); ok(HttpQueryInfoA(hRequest,HTTP_QUERY_CUSTOM|HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer,&len,&index) == FALSE,"Query succeeded on a too small buffer\n"); + ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected last error: %d\n", GetLastError()); + ok(index == 0, "Index was incremented\n"); ok(strcmp(buffer,"Warning")==0, "incorrect string was returned(%s)\n",buffer); /* string not touched */ ok(len == 6, "Invalid length (exp. 6, got %d)\n", len); /* unlike success, the length includes the NULL-terminator */ @@ -1643,7 +1724,7 @@ ok((len < sizeof(buffer)-sizeof(CHAR)) && (buffer[len/sizeof(CHAR)] == 0),"No NUL at end\n"); ok(len == strlen(buffer) * sizeof(CHAR), "Length wrong\n"); /* what's in the middle differs between Wine and Windows so currently we check only the beginning and the end */ - ok(strncmp(buffer, "POST /posttest.php HTTP/1", 25)==0, "Invalid beginning of headers string\n"); + ok(strncmp(buffer, "POST /tests/post.php HTTP/1", 25)==0, "Invalid beginning of headers string\n"); ok(strcmp(buffer + strlen(buffer) - 4, "\r\n\r\n")==0, "Invalid end of headers string\n"); ok(index == 0, "Index was incremented\n"); @@ -1952,7 +2033,7 @@ static DWORD CALLBACK server_thread(LPVOID param) { struct server_info *si = param; - int r, c, i, on, count = 0; + int r, c = -1, i, on, count = 0; SOCKET s; struct sockaddr_in sa; char buffer[0x100]; @@ -1988,7 +2069,8 @@ do { - c = accept(s, NULL, NULL); + if(c == -1) + c = accept(s, NULL, NULL); memset(buffer, 0, sizeof buffer); for(i=0; i<(sizeof buffer-1); i++) @@ -2194,6 +2276,16 @@ else send(c, notokmsg, sizeof(notokmsg)-1, 0); } + if (strstr(buffer, "HEAD /test_head")) { + static const char head_response[] = + "HTTP/1.1 200 OK\r\n" + "Connection: Keep-Alive\r\n" + "Content-Length: 100\r\n" + "\r\n"; + + send(c, head_response, sizeof(head_response), 0); + continue; + } if (strstr(buffer, "GET /send_from_buffer")) send(c, send_buffer, strlen(send_buffer), 0); if (strstr(buffer, "/test_cache_control_verb")) @@ -2208,6 +2300,7 @@ shutdown(c, 2); closesocket(c); + c = -1; } while (!last_request); closesocket(s); @@ -2659,10 +2752,10 @@ { static const char authorization[] = "Authorization: Basic dXNlcjpwd2Q="; static const char connection[] = "Connection: Close"; - static const char *types[2] = { "*", NULL }; + char data[32]; HINTERNET session, connect, request; - DWORD size, status; + DWORD size, status, data_len; BOOL ret; session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); @@ -2698,6 +2791,10 @@ ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status); InternetCloseHandle(request); + InternetCloseHandle(connect); + + connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); request = HttpOpenRequestA(connect, "POST", "/test7", NULL, NULL, types, INTERNET_FLAG_KEEP_CONNECTION, 0); ok(request != NULL, "HttpOpenRequest failed\n"); @@ -2712,7 +2809,30 @@ size = sizeof(status); ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); ok(ret, "HttpQueryInfo failed\n"); - ok(status == 200 || status == 400 /* IE6 */, "got status %u, expected 200 or 400\n", status); + ok(status == 200, "got status %u, expected 200\n", status); + + InternetCloseHandle(request); + InternetCloseHandle(connect); + + connect = InternetConnectA(session, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(connect != NULL, "InternetConnect failed\n"); + + request = HttpOpenRequestA(connect, "POST", "/test7b", NULL, NULL, types, 0, 0); + ok(request != NULL, "HttpOpenRequest failed\n"); + + ret = HttpAddRequestHeadersA(request, "Content-Length: 100\r\n", ~0u, HTTP_ADDREQ_FLAG_ADD_IF_NEW); + ok(ret, "HttpAddRequestHeaders failed\n"); + + data_len = sizeof(data); + memset(data, 'a', sizeof(data)); + ret = HttpSendRequestA(request, connection, ~0u, data, data_len); + ok(ret, "HttpSendRequest failed\n"); + + status = 0; + size = sizeof(status); + ret = HttpQueryInfoA( request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &size, NULL ); + ok(ret, "HttpQueryInfo failed\n"); + ok(status == 200, "got status %u, expected 200\n", status); InternetCloseHandle(request); InternetCloseHandle(connect); @@ -3134,21 +3254,24 @@ res = InternetReadFile(req, buf, avail, &size); ok(res, "InternetReadFile failed: %u\n", GetLastError()); + /* IE11 calls those in InternetQueryDataAvailable call. */ + SET_OPTIONAL(INTERNET_STATUS_RECEIVING_RESPONSE); + SET_OPTIONAL(INTERNET_STATUS_RESPONSE_RECEIVED); + res = InternetQueryDataAvailable(req, &avail, 0, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); ok(!avail, "avail = %u, expected 0\n", avail); + CLEAR_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); SetEvent(conn_close_event); -#ifdef ROSTESTS_73_FIXED WaitForSingleObject(hCompleteEvent, INFINITE); -#else /* ROSTESTS_73_FIXED */ - ok(WaitForSingleObject(hCompleteEvent, 5000) == WAIT_OBJECT_0, "Wait timed out\n"); -#endif /* ROSTESTS_73_FIXED */ ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); + CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); @@ -3583,6 +3706,45 @@ InternetCloseHandle(hr); InternetCloseHandle(hc); InternetCloseHandle(hi); +} + +static void test_head_request(int port) +{ + DWORD len, content_length; + HINTERNET ses, con, req; + BYTE buf[100]; + BOOL ret; + + ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + ok(ses != NULL, "InternetOpen failed\n"); + + con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + ok(con != NULL, "InternetConnect failed\n"); + + req = HttpOpenRequestA(con, "HEAD", "/test_head", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0); + ok(req != NULL, "HttpOpenRequest failed\n"); + + ret = HttpSendRequestA(req, NULL, 0, NULL, 0); + ok(ret, "HttpSendRequest failed: %u\n", GetLastError()); + + len = sizeof(content_length); + content_length = -1; + ret = HttpQueryInfoA(req, HTTP_QUERY_FLAG_NUMBER|HTTP_QUERY_CONTENT_LENGTH, &content_length, &len, 0); + ok(ret, "HttpQueryInfo dailed: %u\n", GetLastError()); + ok(len == sizeof(DWORD), "len = %u\n", len); + ok(content_length == 100, "content_length = %u\n", content_length); + + len = -1; + ret = InternetReadFile(req, buf, sizeof(buf), &len); + ok(ret, "InternetReadFile failed: %u\n", GetLastError()); + + len = -1; + ret = InternetReadFile(req, buf, sizeof(buf), &len); + ok(ret, "InternetReadFile failed: %u\n", GetLastError()); + + InternetCloseHandle(req); + InternetCloseHandle(con); + InternetCloseHandle(ses); } static void test_HttpQueryInfo(int port) @@ -3998,6 +4160,7 @@ test_connection_closing(si.port); test_cache_control_verb(si.port); test_successive_HttpSendRequest(si.port); + test_head_request(si.port); /* send the basic request again to shutdown the server thread */ test_basic_request(si.port, "GET", "/quit"); @@ -4066,7 +4229,7 @@ ok(!info.lpszSignatureAlgName, "lpszSignatureAlgName = %s\n", info.lpszSignatureAlgName); ok(!info.lpszEncryptionAlgName, "lpszEncryptionAlgName = %s\n", info.lpszEncryptionAlgName); ok(!info.lpszProtocolName, "lpszProtocolName = %s\n", info.lpszProtocolName); - ok(info.dwKeySize == 128, "dwKeySize = %u\n", info.dwKeySize); + ok(info.dwKeySize == 128 || info.dwKeySize == 256, "dwKeySize = %u\n", info.dwKeySize); release_cert_info(&info); } @@ -4099,8 +4262,8 @@ } } -#define test_secflags_option(a,b) _test_secflags_option(__LINE__,a,b) -static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags) +#define test_secflags_option(a,b,c) _test_secflags_option(__LINE__,a,b,c) +static void _test_secflags_option(unsigned line, HINTERNET req, DWORD ex_flags, DWORD opt_flags) { DWORD flags, size; BOOL res; @@ -4109,14 +4272,16 @@ size = sizeof(flags); res = InternetQueryOptionW(req, INTERNET_OPTION_SECURITY_FLAGS, &flags, &size); ok_(__FILE__,line)(res, "InternetQueryOptionW(INTERNET_OPTION_SECURITY_FLAGS) failed: %u\n", GetLastError()); - ok_(__FILE__,line)(flags == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n", flags, ex_flags); + ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS flags = %x, expected %x\n", + flags, ex_flags); /* Option 98 is undocumented and seems to be the same as INTERNET_OPTION_SECURITY_FLAGS */ flags = 0xdeadbeef; size = sizeof(flags); res = InternetQueryOptionW(req, 98, &flags, &size); ok_(__FILE__,line)(res, "InternetQueryOptionW(98) failed: %u\n", GetLastError()); - ok_(__FILE__,line)(flags == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n", flags, ex_flags); + ok_(__FILE__,line)((flags & ~opt_flags) == ex_flags, "INTERNET_OPTION_SECURITY_FLAGS(98) flags = %x, expected %x\n", + flags, ex_flags); } #define set_secflags(a,b,c) _set_secflags(__LINE__,a,b,c) @@ -4169,17 +4334,17 @@ return; } - test_secflags_option(req, 0); + test_secflags_option(req, 0, 0); test_security_info("
https://test.winehq.com/data/some_file.html?q
", ERROR_INTERNET_ITEM_NOT_FOUND, 0); set_secflags(req, TRUE, SECURITY_FLAG_IGNORE_REVOCATION); - test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION); + test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION, 0); set_secflags(req, TRUE, SECURITY_FLAG_IGNORE_CERT_CN_INVALID); - test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID); + test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID, 0); set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_UNKNOWN_CA); - test_secflags_option(req, SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID); + test_secflags_option(req, SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID, 0); flags = SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_SECURE; res = InternetSetOptionW(req, 99, &flags, sizeof(flags)); @@ -4189,6 +4354,10 @@ SET_EXPECT(INTERNET_STATUS_NAME_RESOLVED); SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4205,8 +4374,10 @@ CHECK_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME); CHECK_NOTIFIED(INTERNET_STATUS_NAME_RESOLVED); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4217,7 +4388,7 @@ test_request_flags(req, 0); test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA - |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_STRENGTH_STRONG); + |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_CERT_CN_INVALID|SECURITY_FLAG_STRENGTH_STRONG, 0); res = InternetReadFile(req, buf, sizeof(buf), &size); ok(res, "InternetReadFile failed: %u\n", GetLastError()); @@ -4240,6 +4411,10 @@ SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */ SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); @@ -4277,6 +4452,48 @@ } HeapFree(GetProcessHeap(), 0, cert); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CLOSING_CONNECTION, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); + CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); + + if(req_error != ERROR_INTERNET_SEC_CERT_REV_FAILED) { + win_skip("Unexpected cert errors %u, skipping security flags tests\n", req_error); + + close_async_handle(ses, hCompleteEvent, 3); + CloseHandle(hCompleteEvent); + return; + } + + size = sizeof(buf); + res = HttpQueryInfoA(req, HTTP_QUERY_CONTENT_ENCODING, buf, &size, 0); + ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfoA(HTTP_QUERY_CONTENT_ENCODING) failed: %u\n", GetLastError()); + + test_request_flags(req, 8); + /* IE11 finds both rev failure and invalid CA. Previous versions required rev failure + to be ignored before invalid CA was reported. */ + test_secflags_option(req, _SECURITY_FLAG_CERT_REV_FAILED, _SECURITY_FLAG_CERT_INVALID_CA); + + set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_REVOCATION); + test_secflags_option(req, _SECURITY_FLAG_CERT_REV_FAILED|SECURITY_FLAG_IGNORE_REVOCATION, _SECURITY_FLAG_CERT_INVALID_CA); + + SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); + SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); + SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); + SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY); + + res = HttpSendRequestA(req, NULL, 0, NULL, 0); + ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); + + WaitForSingleObject(hCompleteEvent, INFINITE); + ok(req_error == ERROR_INTERNET_SEC_CERT_ERRORS, "req_error = %d\n", req_error); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); @@ -4285,57 +4502,21 @@ CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); - if(req_error != ERROR_INTERNET_SEC_CERT_REV_FAILED) { - win_skip("Unexpected cert errors %u, skipping security flags tests\n", req_error); - - close_async_handle(ses, hCompleteEvent, 3); - CloseHandle(hCompleteEvent); - return; - } - - size = sizeof(buf); - res = HttpQueryInfoA(req, HTTP_QUERY_CONTENT_ENCODING, buf, &size, 0); - ok(!res && GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND, "HttpQueryInfoA(HTTP_QUERY_CONTENT_ENCODING) failed: %u\n", GetLastError()); - - test_request_flags(req, 8); - test_secflags_option(req, 0x800000); - - set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_REVOCATION); - test_secflags_option(req, 0x800000|SECURITY_FLAG_IGNORE_REVOCATION); + test_request_flags(req, INTERNET_REQFLAG_NO_HEADERS); + test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0); + test_security_info("
https://test.winehq.com/data/some_file.html?q
", ERROR_INTERNET_ITEM_NOT_FOUND, 0); + + set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_UNKNOWN_CA); + test_secflags_option(req, _SECURITY_FLAG_CERT_INVALID_CA|_SECURITY_FLAG_CERT_REV_FAILED + |SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_UNKNOWN_CA, 0); + test_http_version(req); SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); - SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); - SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); - SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); - SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); - SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY); - - res = HttpSendRequestA(req, NULL, 0, NULL, 0); - ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - - WaitForSingleObject(hCompleteEvent, INFINITE); - ok(req_error == ERROR_INTERNET_SEC_CERT_ERRORS, "req_error = %d\n", req_error); - - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); - CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); - CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); - CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); - - test_request_flags(req, INTERNET_REQFLAG_NO_HEADERS); - test_secflags_option(req, SECURITY_FLAG_IGNORE_REVOCATION|0x1800000); - test_security_info("
https://test.winehq.com/data/some_file.html?q
", ERROR_INTERNET_ITEM_NOT_FOUND, 0); - - set_secflags(req, FALSE, SECURITY_FLAG_IGNORE_UNKNOWN_CA); - test_secflags_option(req, 0x1800000|SECURITY_FLAG_IGNORE_REVOCATION|SECURITY_FLAG_IGNORE_UNKNOWN_CA - |SECURITY_FLAG_IGNORE_REVOCATION); - test_http_version(req); - - SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); - SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4350,8 +4531,10 @@ WaitForSingleObject(hCompleteEvent, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4362,10 +4545,11 @@ test_request_flags(req, 0); test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_REVOCATION - |SECURITY_FLAG_STRENGTH_STRONG|0x1800000); + |SECURITY_FLAG_STRENGTH_STRONG|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0); test_cert_struct(req, &test_winehq_com_cert); - test_security_info("
https://test.winehq.com/data/some_file.html?q
", 0, 0x1800000); + test_security_info("
https://test.winehq.com/data/some_file.html?q
", 0, + _SECURITY_FLAG_CERT_INVALID_CA|_SECURITY_FLAG_CERT_REV_FAILED); res = InternetReadFile(req, buf, sizeof(buf), &size); ok(res, "InternetReadFile failed: %u\n", GetLastError()); @@ -4398,11 +4582,15 @@ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED); test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_STRENGTH_STRONG - |SECURITY_FLAG_IGNORE_REVOCATION|0x1800000); + |SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0); test_http_version(req); SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + SET_OPTIONAL(INTERNET_STATUS_CLOSING_CONNECTION); /* IE11 calls it, it probably reconnects. */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTION_CLOSED); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTING_TO_SERVER); /* IE11 */ + SET_OPTIONAL(INTERNET_STATUS_CONNECTED_TO_SERVER); /* IE11 */ SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4416,8 +4604,10 @@ WaitForSingleObject(hCompleteEvent, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); + CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTED_TO_SERVER, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4427,7 +4617,7 @@ test_request_flags(req, 0); test_secflags_option(req, SECURITY_FLAG_SECURE|SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_STRENGTH_STRONG - |SECURITY_FLAG_IGNORE_REVOCATION|0x1800000); + |SECURITY_FLAG_IGNORE_REVOCATION|_SECURITY_FLAG_CERT_REV_FAILED|_SECURITY_FLAG_CERT_INVALID_CA, 0); res = InternetReadFile(req, buf, sizeof(buf), &size); ok(res, "InternetReadFile failed: %u\n", GetLastError()); @@ -4633,7 +4823,6 @@ ret = HttpQueryInfoA(req, HTTP_QUERY_USER_AGENT | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, NULL); err = GetLastError(); ok(ret, "HttpQueryInfo failed\n"); - ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "expected ERROR_HTTP_HEADER_NOT_FOUND, got %u\n", err); InternetCloseHandle(req); @@ -5010,7 +5199,7 @@ sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]), "POST", "
test.winehq.org
", - "tests/posttest.php", + "tests/post.php", "Public ID=codeweavers" }, { @@ -5018,7 +5207,7 @@ sizeof(async_send_request_ex_test)/sizeof(async_send_request_ex_test[0]), "POST", "
test.winehq.org
", - "tests/posttest.php" + "tests/post.php" }, { async_send_request_ex_resolve_failure_test, @@ -5318,7 +5507,6 @@ InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[1]); InternetReadFile_test(0, &test_data[1]); - first_connection_to_test_url = TRUE; InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[2]); test_security_flags(); InternetReadFile_test(0, &test_data[2]); Modified: trunk/rostests/winetests/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/interne…
============================================================================== --- trunk/rostests/winetests/wininet/internet.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/internet.c [iso-8859-1] Thu Sep 25 15:31:51 2014 @@ -190,18 +190,15 @@ ok(retval == 0,"Got wrong return value %d\n",retval); ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err); - SetLastError(0xdeadbeef); len=strlen(useragent)+1; buffer=HeapAlloc(GetProcessHeap(),0,len); retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len); - err=GetLastError(); ok(retval == 1,"Got wrong return value %d\n",retval); if (retval) { ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent); ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent)); } - ok(err == 0xdeadbeef, "Got wrong error code %d\n",err); HeapFree(GetProcessHeap(),0,buffer); SetLastError(0xdeadbeef); @@ -561,6 +558,61 @@ todo_wine ok(!ret, "InternetSetCookie succeeded\n"); } +static void test_cookie_attrs(void) +{ + char buf[100]; + DWORD size, state; + BOOL ret; + + if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "InternetGetSecurityInfoByURLA")) { + win_skip("Skipping cookie attributes tests. Too old IE.\n"); + return; + } + + ret = InternetSetCookieA("
http://cookie.attrs.com/bar
", NULL, "A=data; httponly"); + ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError()); + + SetLastError(0xdeadbeef); + state = InternetSetCookieExA("
http://cookie.attrs.com/bar
", NULL, "A=data; httponly", 0, 0); + ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION, + "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError()); + + size = sizeof(buf); + ret = InternetGetCookieExA("
http://cookie.attrs.com/
", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL); + ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError()); + + state = InternetSetCookieExA("
http://cookie.attrs.com/bar
",NULL,"A=data; httponly", INTERNET_COOKIE_HTTPONLY, 0); + ok(state == COOKIE_STATE_ACCEPT,"InternetSetCookieEx failed: %u\n", GetLastError()); + + size = sizeof(buf); + ret = InternetGetCookieA("
http://cookie.attrs.com/
", NULL, buf, &size); + ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned: %x (%u)\n", ret, GetLastError()); + + size = sizeof(buf); + ret = InternetGetCookieExA("
http://cookie.attrs.com/
", NULL, buf, &size, 0, NULL); + ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError()); + + size = sizeof(buf); + ret = InternetGetCookieExA("
http://cookie.attrs.com/
", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL); + ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError()); + ok(!strcmp(buf, "A=data"), "data = %s\n", buf); + + /* Try to override httponly cookie with non-httponly one */ + ret = InternetSetCookieA("
http://cookie.attrs.com/bar
", NULL, "A=test"); + ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError()); + + SetLastError(0xdeadbeef); + state = InternetSetCookieExA("
http://cookie.attrs.com/bar
", NULL, "A=data", 0, 0); + ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION, + "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError()); + + size = sizeof(buf); + ret = InternetGetCookieExA("
http://cookie.attrs.com/
", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL); + ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError()); + ok(!strcmp(buf, "A=data"), "data = %s\n", buf); + +} + static void test_cookie_url(void) { WCHAR bufw[512]; @@ -595,6 +647,7 @@ { HINTERNET hi, hc; static const WCHAR szServer[] = { 's','e','r','v','e','r',0 }; + static const WCHAR szServer2[] = { 's','e','r','v','e','r','=',0 }; static const WCHAR szEmpty[] = { 0 }; static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 }; static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 }; @@ -687,8 +740,8 @@ r = InternetGetCookieW(szUrl, szServer, NULL, &sz); ok( r == TRUE, "return wrong\n"); - /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */ - ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz); + /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */ + ok( sz == 14 || sz == 16 || sz == 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz); sz = 0x20; memset(buffer, 0, sizeof buffer); @@ -699,7 +752,8 @@ ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz); /* before XP SP2, buffer is "server; server" */ - ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n"); + ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer) || !lstrcmpW(szServer2, buffer), + "cookie data wrong %s\n", wine_dbgstr_w(buffer)); sz = sizeof(buffer); r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz); @@ -1067,11 +1121,9 @@ ok(ret == FALSE, "InternetQueryOption should've failed\n"); ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError()); - SetLastError(0xdeadbeef); ulArg = 11; ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG)); ok(ret == TRUE, "InternetQueryOption should've succeeded\n"); - ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError()); SetLastError(0xdeadbeef); ulArg = 4; @@ -1622,6 +1674,7 @@ test_get_cookie(); test_complicated_cookie(); test_cookie_url(); + test_cookie_attrs(); test_version(); test_null(); test_Option_PerConnectionOption(); Modified: trunk/rostests/winetests/wininet/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/url.c?r…
============================================================================== --- trunk/rostests/winetests/wininet/url.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/url.c [iso-8859-1] Thu Sep 25 15:31:51 2014 @@ -851,12 +851,9 @@ /* alloc-ed szUrl, NULL lpszScheme * shows that it uses nScheme instead */ - SetLastError(0xdeadbeef); urlComp.lpszScheme = NULL; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl); @@ -864,48 +861,36 @@ * any nScheme out of range seems ignored */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.nScheme = -3; len++; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); /* test valid lpUrlComponents, alloc-ed szUrl */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); len = 51; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); ok(strstr(szUrl, "80") == NULL, "Didn't expect to find 80 in szUrl\n"); ok(!strcmp(szUrl, CREATE_URL1), "Expected %s, got %s\n", CREATE_URL1, szUrl); /* valid username, NULL password */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.lpszPassword = NULL; len = 42; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 41, "Expected len 41, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL2), "Expected %s, got %s\n", CREATE_URL2, szUrl); /* valid username, empty password */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.lpszPassword = empty; len = 51; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL3), "Expected %s, got %s\n", CREATE_URL3, szUrl); @@ -927,39 +912,30 @@ * if password is provided, username has to exist */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.lpszUserName = empty; len = 51; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl); /* NULL username, NULL password */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.lpszUserName = NULL; urlComp.lpszPassword = NULL; len = 42; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 32, "Expected len 32, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL4), "Expected %s, got %s\n", CREATE_URL4, szUrl); /* empty username, empty password */ fill_url_components(&urlComp); - SetLastError(0xdeadbeef); urlComp.lpszUserName = empty; urlComp.lpszPassword = empty; len = 51; ret = InternetCreateUrlA(&urlComp, 0, szUrl, &len); ok(ret, "Expected success\n"); - ok(GetLastError() == 0xdeadbeef, - "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(len == 50, "Expected len 50, got %d\n", len); ok(!strcmp(szUrl, CREATE_URL5), "Expected %s, got %s\n", CREATE_URL5, szUrl); Modified: trunk/rostests/winetests/wininet/urlcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/urlcach…
============================================================================== --- trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/urlcache.c [iso-8859-1] Thu Sep 25 15:31:51 2014 @@ -103,6 +103,7 @@ ret = FindCloseUrlCache(hEnumHandle); ok(ret, "FindCloseUrlCache failed with error %d\n", GetLastError()); + HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); } static void test_GetUrlCacheEntryInfoExA(void) @@ -1038,6 +1039,45 @@ ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error); } +static BOOL cache_entry_exists(const char *url) +{ + static char buf[10000]; + DWORD size = sizeof(buf); + BOOL ret; + + ret = GetUrlCacheEntryInfoA(url, (void*)buf, &size); + ok(ret || GetLastError() == ERROR_FILE_NOT_FOUND, "GetUrlCacheEntryInfoA returned %x (%u)\n", ret, GetLastError()); + + return ret; +} + +static void test_trailing_slash(void) +{ + char filename[MAX_PATH]; + BYTE zero_byte = 0; + BOOL ret; + + static const FILETIME filetime_zero; + static char url_with_slash[] = "
http://testing.cache.com/
"; + + + ret = CreateUrlCacheEntryA(url_with_slash, 0, "html", filename, 0); + ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); + + create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); + + ret = CommitUrlCacheEntryA("Visited:
http://testing.cache.com/
", NULL, filetime_zero, filetime_zero, + NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); + ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); + + ok(cache_entry_exists("Visited:
http://testing.cache.com/
"), "cache entry does not exist\n"); + ok(!cache_entry_exists("Visited:
http://testing.cache.com
"), "cache entry exists\n"); + + ret = DeleteUrlCacheEntryA("Visited:
http://testing.cache.com/
"); + ok(ret, "DeleteCacheEntryA failed\n"); + DeleteFileA(filename); +} + START_TEST(urlcache) { HMODULE hdll; @@ -1061,4 +1101,5 @@ test_urlcacheW(); test_FindCloseUrlCache(); test_GetDiskInfoA(); -} + test_trailing_slash(); +}
10 years, 3 months
1
0
0
0
[akhaldi] 64276: [WININET] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:31:21 2014 New Revision: 64276 URL:
http://svn.reactos.org/svn/reactos?rev=64276&view=rev
Log: [WININET] * Sync with Wine 1.7.27. CORE-8540 Removed: trunk/reactos/dll/win32/wininet/wininet_main.c Modified: trunk/reactos/dll/win32/wininet/CMakeLists.txt trunk/reactos/dll/win32/wininet/cookie.c trunk/reactos/dll/win32/wininet/ftp.c trunk/reactos/dll/win32/wininet/http.c trunk/reactos/dll/win32/wininet/internet.c trunk/reactos/dll/win32/wininet/internet.h trunk/reactos/dll/win32/wininet/netconnection.c trunk/reactos/dll/win32/wininet/urlcache.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wininet/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/CMakeLis…
============================================================================== --- trunk/reactos/dll/win32/wininet/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/CMakeLists.txt [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -19,7 +19,6 @@ netconnection.c urlcache.c utility.c - wininet_main.c internet.h) add_library(wininet SHARED Modified: trunk/reactos/dll/win32/wininet/cookie.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/cookie.c…
============================================================================== --- trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -28,30 +28,42 @@ * Cookies could use A LOT OF MEMORY. We need some kind of memory management here! */ -typedef struct _cookie_domain cookie_domain; -typedef struct _cookie cookie; - -struct _cookie -{ +struct _cookie_domain_t; +struct _cookie_container_t; + +typedef struct _cookie_t { struct list entry; - struct _cookie_domain *parent; - - LPWSTR lpCookieName; - LPWSTR lpCookieData; + struct _cookie_container_t *container; + + WCHAR *name; + WCHAR *data; DWORD flags; FILETIME expiry; FILETIME create; -}; - -struct _cookie_domain -{ +} cookie_t; + +typedef struct _cookie_container_t { struct list entry; - LPWSTR lpCookieDomain; - LPWSTR lpCookiePath; + WCHAR *path; + struct _cookie_domain_t *domain; + struct list cookie_list; -}; +} cookie_container_t; + +typedef struct _cookie_domain_t { + struct list entry; + + WCHAR *domain; + unsigned subdomain_len; + + struct _cookie_domain_t *parent; + struct list subdomain_list; + + /* List of stored paths sorted by length of the path. */ + struct list path_list; +} cookie_domain_t; static CRITICAL_SECTION cookie_cs; static CRITICAL_SECTION_DEBUG cookie_cs_debug = @@ -63,14 +75,172 @@ static CRITICAL_SECTION cookie_cs = { &cookie_cs_debug, -1, 0, 0, 0, 0 }; static struct list domain_list = LIST_INIT(domain_list); -static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, - FILETIME expiry, FILETIME create, DWORD flags); -static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName); -static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain); -static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path); -static void COOKIE_deleteDomain(cookie_domain *deadDomain); -static BOOL COOKIE_matchDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath, - cookie_domain *searchDomain, BOOL allow_partial); +static cookie_domain_t *get_cookie_domain(const WCHAR *domain, BOOL create) +{ + const WCHAR *ptr = domain + strlenW(domain), *ptr_end, *subdomain_ptr; + cookie_domain_t *iter, *current_domain, *prev_domain = NULL; + struct list *current_list = &domain_list; + + while(1) { + for(ptr_end = ptr--; ptr > domain && *ptr != '.'; ptr--); + subdomain_ptr = *ptr == '.' ? ptr+1 : ptr; + + current_domain = NULL; + LIST_FOR_EACH_ENTRY(iter, current_list, cookie_domain_t, entry) { + if(ptr_end-subdomain_ptr == iter->subdomain_len && !memcmp(subdomain_ptr, iter->domain, iter->subdomain_len)) { + current_domain = iter; + break; + } + } + + if(!current_domain) { + if(!create) + return prev_domain; + + current_domain = heap_alloc(sizeof(*current_domain)); + if(!current_domain) + return NULL; + + current_domain->domain = heap_strdupW(subdomain_ptr); + if(!current_domain->domain) { + heap_free(current_domain); + return NULL; + } + + current_domain->subdomain_len = ptr_end-subdomain_ptr; + + current_domain->parent = prev_domain; + list_init(¤t_domain->path_list); + list_init(¤t_domain->subdomain_list); + + list_add_tail(current_list, ¤t_domain->entry); + } + + if(ptr == domain) + return current_domain; + + prev_domain = current_domain; + current_list = ¤t_domain->subdomain_list; + } +} + +static cookie_container_t *get_cookie_container(const WCHAR *domain, const WCHAR *path, BOOL create) +{ + cookie_domain_t *cookie_domain; + cookie_container_t *cookie_container, *iter; + size_t path_len, len; + + cookie_domain = get_cookie_domain(domain, create); + if(!cookie_domain) + return NULL; + + path_len = strlenW(path); + + LIST_FOR_EACH_ENTRY(cookie_container, &cookie_domain->path_list, cookie_container_t, entry) { + len = strlenW(cookie_container->path); + if(len < path_len) + break; + + if(!strcmpiW(cookie_container->path, path)) + return cookie_container; + } + + if(!create) + return NULL; + + cookie_container = heap_alloc(sizeof(*cookie_container)); + if(!cookie_container) + return NULL; + + cookie_container->path = heap_strdupW(path); + if(!cookie_container->path) { + heap_free(cookie_container); + return NULL; + } + + cookie_container->domain = cookie_domain; + list_init(&cookie_container->cookie_list); + + + LIST_FOR_EACH_ENTRY(iter, &cookie_domain->path_list, cookie_container_t, entry) { + if(strlenW(iter->path) <= path_len) { + list_add_before(&iter->entry, &cookie_container->entry); + return cookie_container; + } + } + + list_add_tail(&cookie_domain->path_list, &cookie_container->entry); + return cookie_container; +} + +static void delete_cookie(cookie_t *cookie) +{ + list_remove(&cookie->entry); + + heap_free(cookie->name); + heap_free(cookie->data); + heap_free(cookie); +} + +static cookie_t *alloc_cookie(const WCHAR *name, const WCHAR *data, FILETIME expiry, FILETIME create_time, DWORD flags) +{ + cookie_t *new_cookie; + + new_cookie = heap_alloc(sizeof(*new_cookie)); + if(!new_cookie) + return NULL; + + new_cookie->expiry = expiry; + new_cookie->create = create_time; + new_cookie->flags = flags; + list_init(&new_cookie->entry); + + new_cookie->name = heap_strdupW(name); + new_cookie->data = heap_strdupW(data); + if((name && !new_cookie->name) || (data && !new_cookie->data)) { + delete_cookie(new_cookie); + return NULL; + } + + return new_cookie; +} + +static cookie_t *find_cookie(cookie_container_t *container, const WCHAR *name) +{ + cookie_t *iter; + + LIST_FOR_EACH_ENTRY(iter, &container->cookie_list, cookie_t, entry) { + if(!strcmpiW(iter->name, name)) + return iter; + } + + return NULL; +} + +static void add_cookie(cookie_container_t *container, cookie_t *new_cookie) +{ + TRACE("Adding %s=%s to %s %s\n", debugstr_w(new_cookie->name), debugstr_w(new_cookie->data), + debugstr_w(container->domain->domain), debugstr_w(container->path)); + + list_add_tail(&container->cookie_list, &new_cookie->entry); + new_cookie->container = container; +} + +static void replace_cookie(cookie_container_t *container, cookie_t *new_cookie) +{ + cookie_t *old_cookie; + + old_cookie = find_cookie(container, new_cookie->name); + if(old_cookie) + delete_cookie(old_cookie); + + add_cookie(container, new_cookie); +} + +static BOOL cookie_match_path(cookie_container_t *container, const WCHAR *path) +{ + return !strncmpiW(container->path, path, strlenW(container->path)); +} static BOOL create_cookie_url(LPCWSTR domain, LPCWSTR path, WCHAR *buf, DWORD buf_len) { @@ -120,9 +290,8 @@ static BOOL load_persistent_cookie(LPCWSTR domain, LPCWSTR path) { INTERNET_CACHE_ENTRY_INFOW *info; - cookie_domain *domain_container = NULL; - cookie *old_cookie; - struct list *iter; + cookie_container_t *cookie_container; + cookie_t *new_cookie; WCHAR cookie_url[MAX_PATH]; HANDLE cookie; char *str = NULL, *pbeg, *pend; @@ -154,19 +323,9 @@ str[size] = 0; UnlockUrlCacheEntryStream(cookie, 0); - LIST_FOR_EACH(iter, &domain_list) - { - domain_container = LIST_ENTRY(iter, cookie_domain, entry); - if(COOKIE_matchDomain(domain, path, domain_container, FALSE)) - break; - domain_container = NULL; - } - if(!domain_container) - domain_container = COOKIE_addDomain(domain, path); - if(!domain_container) { - heap_free(str); - return FALSE; - } + cookie_container = get_cookie_container(domain, path, TRUE); + if(!cookie_container) + return FALSE; GetSystemTimeAsFileTime(&time); for(pbeg=str; pbeg && *pbeg; name=data=NULL) { @@ -202,12 +361,18 @@ break; if(CompareFileTime(&time, &expiry) <= 0) { - if((old_cookie = COOKIE_findCookie(domain_container, name))) - COOKIE_deleteCookie(old_cookie, FALSE); - COOKIE_addCookie(domain_container, name, data, expiry, create, flags); - } - heap_free(name); - heap_free(data); + new_cookie = alloc_cookie(NULL, NULL, expiry, create, flags); + if(!new_cookie) + break; + + new_cookie->name = name; + new_cookie->data = data; + + replace_cookie(cookie_container, new_cookie); + }else { + heap_free(name); + heap_free(data); + } } heap_free(str); heap_free(name); @@ -216,28 +381,28 @@ return TRUE; } -static BOOL save_persistent_cookie(cookie_domain *domain) +static BOOL save_persistent_cookie(cookie_container_t *container) { static const WCHAR txtW[] = {'t','x','t',0}; WCHAR cookie_url[MAX_PATH], cookie_file[MAX_PATH]; HANDLE cookie_handle; - cookie *cookie_container = NULL, *cookie_iter; + cookie_t *cookie_container = NULL, *cookie_iter; BOOL do_save = FALSE; char buf[64], *dyn_buf; FILETIME time; - DWORD dwBytesWritten; - - if (!create_cookie_url(domain->lpCookieDomain, domain->lpCookiePath, cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) + DWORD bytes_written; + + if (!create_cookie_url(container->domain->domain, container->path, cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) return FALSE; /* check if there's anything to save */ GetSystemTimeAsFileTime(&time); - LIST_FOR_EACH_ENTRY_SAFE(cookie_container, cookie_iter, &domain->cookie_list, cookie, entry) + LIST_FOR_EACH_ENTRY_SAFE(cookie_container, cookie_iter, &container->cookie_list, cookie_t, entry) { if((cookie_container->expiry.dwLowDateTime || cookie_container->expiry.dwHighDateTime) && CompareFileTime(&time, &cookie_container->expiry) > 0) { - COOKIE_deleteCookie(cookie_container, FALSE); + delete_cookie(cookie_container); continue; } @@ -259,45 +424,45 @@ return FALSE; } - LIST_FOR_EACH_ENTRY(cookie_container, &domain->cookie_list, cookie, entry) + LIST_FOR_EACH_ENTRY(cookie_container, &container->cookie_list, cookie_t, entry) { if(cookie_container->flags & INTERNET_COOKIE_IS_SESSION) continue; - dyn_buf = heap_strdupWtoA(cookie_container->lpCookieName); - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) { + dyn_buf = heap_strdupWtoA(cookie_container->name); + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { heap_free(dyn_buf); do_save = FALSE; break; } heap_free(dyn_buf); - if(!WriteFile(cookie_handle, "\n", 1, &dwBytesWritten, NULL)) { + if(!WriteFile(cookie_handle, "\n", 1, &bytes_written, NULL)) { do_save = FALSE; break; } - dyn_buf = heap_strdupWtoA(cookie_container->lpCookieData); - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) { + dyn_buf = heap_strdupWtoA(cookie_container->data); + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { heap_free(dyn_buf); do_save = FALSE; break; } heap_free(dyn_buf); - if(!WriteFile(cookie_handle, "\n", 1, &dwBytesWritten, NULL)) { + if(!WriteFile(cookie_handle, "\n", 1, &bytes_written, NULL)) { do_save = FALSE; break; } - dyn_buf = heap_strdupWtoA(domain->lpCookieDomain); - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) { + dyn_buf = heap_strdupWtoA(container->domain->domain); + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { heap_free(dyn_buf); do_save = FALSE; break; } heap_free(dyn_buf); - dyn_buf = heap_strdupWtoA(domain->lpCookiePath); - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) { + dyn_buf = heap_strdupWtoA(container->path); + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &bytes_written, NULL)) { heap_free(dyn_buf); do_save = FALSE; break; @@ -307,7 +472,7 @@ sprintf(buf, "\n%u\n%u\n%u\n%u\n%u\n*\n", cookie_container->flags, cookie_container->expiry.dwLowDateTime, cookie_container->expiry.dwHighDateTime, cookie_container->create.dwLowDateTime, cookie_container->create.dwHighDateTime); - if(!WriteFile(cookie_handle, buf, strlen(buf), &dwBytesWritten, NULL)) { + if(!WriteFile(cookie_handle, buf, strlen(buf), &bytes_written, NULL)) { do_save = FALSE; break; } @@ -322,90 +487,6 @@ memset(&time, 0, sizeof(time)); return CommitUrlCacheEntryW(cookie_url, cookie_file, time, time, 0, NULL, 0, txtW, 0); -} - -/* adds a cookie to the domain */ -static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR data, - FILETIME expiry, FILETIME create, DWORD flags) -{ - cookie *newCookie = heap_alloc(sizeof(cookie)); - if (!newCookie) - return NULL; - - newCookie->lpCookieName = heap_strdupW(name); - newCookie->lpCookieData = heap_strdupW(data); - - if (!newCookie->lpCookieName || !newCookie->lpCookieData) - { - heap_free(newCookie->lpCookieName); - heap_free(newCookie->lpCookieData); - heap_free(newCookie); - - return NULL; - } - - newCookie->flags = flags; - newCookie->expiry = expiry; - newCookie->create = create; - - TRACE("added cookie %p (data is %s)\n", newCookie, debugstr_w(data) ); - - list_add_tail(&domain->cookie_list, &newCookie->entry); - newCookie->parent = domain; - return newCookie; -} - - -/* finds a cookie in the domain matching the cookie name */ -static cookie *COOKIE_findCookie(cookie_domain *domain, LPCWSTR lpszCookieName) -{ - struct list * cursor; - TRACE("(%p, %s)\n", domain, debugstr_w(lpszCookieName)); - - LIST_FOR_EACH(cursor, &domain->cookie_list) - { - cookie *searchCookie = LIST_ENTRY(cursor, cookie, entry); - BOOL candidate = TRUE; - if (candidate && lpszCookieName) - { - if (candidate && !searchCookie->lpCookieName) - candidate = FALSE; - if (candidate && strcmpW(lpszCookieName, searchCookie->lpCookieName) != 0) - candidate = FALSE; - } - if (candidate) - return searchCookie; - } - return NULL; -} - -/* removes a cookie from the list, if its the last cookie we also remove the domain */ -static void COOKIE_deleteCookie(cookie *deadCookie, BOOL deleteDomain) -{ - heap_free(deadCookie->lpCookieName); - heap_free(deadCookie->lpCookieData); - list_remove(&deadCookie->entry); - - /* special case: last cookie, lets remove the domain to save memory */ - if (list_empty(&deadCookie->parent->cookie_list) && deleteDomain) - COOKIE_deleteDomain(deadCookie->parent); - heap_free(deadCookie); -} - -/* allocates a domain and adds it to the end */ -static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path) -{ - cookie_domain *newDomain = heap_alloc(sizeof(cookie_domain)); - - list_init(&newDomain->entry); - list_init(&newDomain->cookie_list); - newDomain->lpCookieDomain = heap_strdupW(domain); - newDomain->lpCookiePath = heap_strdupW(path); - - list_add_tail(&domain_list, &newDomain->entry); - - TRACE("Adding domain: %p\n", newDomain); - return newDomain; } static BOOL COOKIE_crackUrlSimple(LPCWSTR lpszUrl, LPWSTR hostName, int hostNameLen, LPWSTR path, int pathLen) @@ -449,77 +530,26 @@ return TRUE; } -/* match a domain. domain must match if the domain is not NULL. path must match if the path is not NULL */ -static BOOL COOKIE_matchDomain(LPCWSTR lpszCookieDomain, LPCWSTR lpszCookiePath, - cookie_domain *searchDomain, BOOL allow_partial) -{ - TRACE("searching on domain %p\n", searchDomain); - if (lpszCookieDomain) - { - if (!searchDomain->lpCookieDomain) - return FALSE; - - TRACE("comparing domain %s with %s\n", - debugstr_w(lpszCookieDomain), - debugstr_w(searchDomain->lpCookieDomain)); - - if (allow_partial && !strstrW(lpszCookieDomain, searchDomain->lpCookieDomain)) - return FALSE; - else if (!allow_partial && lstrcmpW(lpszCookieDomain, searchDomain->lpCookieDomain) != 0) - return FALSE; - } - if (lpszCookiePath) - { - INT len; - TRACE("comparing paths: %s with %s\n", debugstr_w(lpszCookiePath), debugstr_w(searchDomain->lpCookiePath)); - /* paths match at the beginning. so a path of /foo would match - * /foobar and /foo/bar - */ - if (!searchDomain->lpCookiePath) - return FALSE; - if (allow_partial) - { - len = lstrlenW(searchDomain->lpCookiePath); - if (strncmpiW(searchDomain->lpCookiePath, lpszCookiePath, len)!=0) - return FALSE; - } - else if (strcmpW(lpszCookiePath, searchDomain->lpCookiePath)) - return FALSE; - - } - return TRUE; -} - -/* remove a domain from the list and delete it */ -static void COOKIE_deleteDomain(cookie_domain *deadDomain) -{ - struct list * cursor; - while ((cursor = list_tail(&deadDomain->cookie_list))) - { - COOKIE_deleteCookie(LIST_ENTRY(cursor, cookie, entry), FALSE); - list_remove(cursor); - } - heap_free(deadDomain->lpCookieDomain); - heap_free(deadDomain->lpCookiePath); - - list_remove(&deadDomain->entry); - - heap_free(deadDomain); -} - -DWORD get_cookie(const WCHAR *host, const WCHAR *path, WCHAR *cookie_data, DWORD *size) +typedef struct { + cookie_t **cookies; + unsigned cnt; + unsigned size; + + unsigned string_len; +} cookie_set_t; + +static DWORD get_cookie(const WCHAR *host, const WCHAR *path, DWORD flags, cookie_set_t *res) { static const WCHAR empty_path[] = { '/',0 }; - unsigned cnt = 0, len, name_len, domain_count = 0, cookie_count = 0; WCHAR *ptr, subpath[INTERNET_MAX_PATH_LENGTH]; const WCHAR *p; - cookie_domain *domain; + cookie_domain_t *domain; + cookie_container_t *container; + unsigned len; FILETIME tm; GetSystemTimeAsFileTime(&tm); - - EnterCriticalSection(&cookie_cs); len = strlenW(host); p = host+len; @@ -544,88 +574,139 @@ while(ptr>subpath && ptr[-1]!='/') ptr--; }while(ptr != subpath); - ptr = cookie_data; - LIST_FOR_EACH_ENTRY(domain, &domain_list, cookie_domain, entry) { - struct list *cursor, *cursor2; - - if(!COOKIE_matchDomain(host, path, domain, TRUE)) - continue; - - domain_count++; - TRACE("found domain %p\n", domain); - - LIST_FOR_EACH_SAFE(cursor, cursor2, &domain->cookie_list) { - cookie *cookie_iter = LIST_ENTRY(cursor, cookie, entry); - - /* check for expiry */ - if((cookie_iter->expiry.dwLowDateTime != 0 || cookie_iter->expiry.dwHighDateTime != 0) - && CompareFileTime(&tm, &cookie_iter->expiry) > 0) - { - TRACE("Found expired cookie. deleting\n"); - COOKIE_deleteCookie(cookie_iter, FALSE); + domain = get_cookie_domain(host, FALSE); + if(!domain) { + TRACE("Unknown host %s\n", debugstr_w(host)); + return ERROR_NO_MORE_ITEMS; + } + + for(domain = get_cookie_domain(host, FALSE); domain; domain = domain->parent) { + TRACE("Trying %s domain...\n", debugstr_w(domain->domain)); + + LIST_FOR_EACH_ENTRY(container, &domain->path_list, cookie_container_t, entry) { + struct list *cursor, *cursor2; + + TRACE("path %s\n", debugstr_w(container->path)); + + if(!cookie_match_path(container, path)) continue; + + TRACE("found domain %p\n", domain->domain); + + LIST_FOR_EACH_SAFE(cursor, cursor2, &container->cookie_list) { + cookie_t *cookie_iter = LIST_ENTRY(cursor, cookie_t, entry); + + /* check for expiry */ + if((cookie_iter->expiry.dwLowDateTime != 0 || cookie_iter->expiry.dwHighDateTime != 0) + && CompareFileTime(&tm, &cookie_iter->expiry) > 0) { + TRACE("Found expired cookie. deleting\n"); + delete_cookie(cookie_iter); + continue; + } + + if((cookie_iter->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) + continue; + + + if(!res->size) { + res->cookies = heap_alloc(4*sizeof(*res->cookies)); + if(!res->cookies) + continue; + res->size = 4; + }else if(res->cnt == res->size) { + cookie_t **new_cookies = heap_realloc(res->cookies, res->size*2*sizeof(*res->cookies)); + if(!new_cookies) + continue; + res->cookies = new_cookies; + res->size *= 2; + } + + if(res->cnt) + res->string_len += 2; /* '; ' */ + res->cookies[res->cnt++] = cookie_iter; + + res->string_len += strlenW(cookie_iter->name); + if(*cookie_iter->data) + res->string_len += 1 /* = */ + strlenW(cookie_iter->data); } - - if (cookie_count) - cnt += 2; /* '; ' */ - cnt += name_len = strlenW(cookie_iter->lpCookieName); - if ((len = strlenW(cookie_iter->lpCookieData))) { - cnt += 1; /* = */ - cnt += len; - } - - if(ptr) { - if(*size > cnt) { - if(cookie_count) { - *ptr++ = ';'; - *ptr++ = ' '; - } - - memcpy(ptr, cookie_iter->lpCookieName, name_len*sizeof(WCHAR)); - ptr += name_len; - - if(len) { - *ptr++ = '='; - memcpy(ptr, cookie_iter->lpCookieData, len*sizeof(WCHAR)); - ptr += len; - } - - assert(cookie_data+cnt == ptr); - TRACE("Cookie: %s\n", debugstr_wn(cookie_data, cnt)); - }else { - /* Stop writing data, just compute the size */ - ptr = NULL; - } - } - - cookie_count++; - } + } + } + + return ERROR_SUCCESS; +} + +static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str) +{ + WCHAR *ptr = str; + unsigned i, len; + + for(i=0; i<cookie_set->cnt; i++) { + if(i) { + *ptr++ = ';'; + *ptr++ = ' '; + } + + len = strlenW(cookie_set->cookies[i]->name); + memcpy(ptr, cookie_set->cookies[i]->name, len*sizeof(WCHAR)); + ptr += len; + + if(*cookie_set->cookies[i]->data) { + *ptr++ = '='; + len = strlenW(cookie_set->cookies[i]->data); + memcpy(ptr, cookie_set->cookies[i]->data, len*sizeof(WCHAR)); + ptr += len; + } + } + + assert(ptr-str == cookie_set->string_len); + TRACE("%s\n", debugstr_wn(str, ptr-str)); +} + +DWORD get_cookie_header(const WCHAR *host, const WCHAR *path, WCHAR **ret) +{ + cookie_set_t cookie_set = {0}; + DWORD res; + + static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '}; + + EnterCriticalSection(&cookie_cs); + + res = get_cookie(host, path, INTERNET_COOKIE_HTTPONLY, &cookie_set); + if(res != ERROR_SUCCESS) { + LeaveCriticalSection(&cookie_cs); + return res; + } + + if(cookie_set.cnt) { + WCHAR *header, *ptr; + + ptr = header = heap_alloc(sizeof(cookieW) + (cookie_set.string_len + 3 /* crlf0 */) * sizeof(WCHAR)); + if(header) { + memcpy(ptr, cookieW, sizeof(cookieW)); + ptr += sizeof(cookieW)/sizeof(*cookieW); + + cookie_set_to_string(&cookie_set, ptr); + heap_free(cookie_set.cookies); + ptr += cookie_set.string_len; + + *ptr++ = '\r'; + *ptr++ = '\n'; + *ptr++ = 0; + + *ret = header; + }else { + res = ERROR_NOT_ENOUGH_MEMORY; + } + }else { + *ret = NULL; } LeaveCriticalSection(&cookie_cs); - - if(ptr) - *ptr = 0; - - if (!cnt) { - TRACE("no cookies found for %s\n", debugstr_w(host)); - return ERROR_NO_MORE_ITEMS; - } - - if(!cookie_data || !ptr) { - *size = (cnt + 1) * sizeof(WCHAR); - TRACE("returning %u\n", *size); - return cookie_data ? ERROR_INSUFFICIENT_BUFFER : ERROR_SUCCESS; - } - - *size = cnt + 1; - - TRACE("Returning %u (from %u domains): %s\n", cnt, domain_count, debugstr_w(cookie_data)); return ERROR_SUCCESS; } /*********************************************************************** - * InternetGetCookieW (WININET.@) + * InternetGetCookieExW (WININET.@) * * Retrieve cookie from the specified url * @@ -637,14 +718,18 @@ * FALSE on failure * */ -BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, - LPWSTR lpCookieData, LPDWORD lpdwSize) +BOOL WINAPI InternetGetCookieExW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, + LPWSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved) { WCHAR host[INTERNET_MAX_HOST_NAME_LENGTH], path[INTERNET_MAX_PATH_LENGTH]; + cookie_set_t cookie_set = {0}; DWORD res; BOOL ret; - TRACE("(%s, %s, %p, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName), lpCookieData, lpdwSize); + TRACE("(%s, %s, %p, %p, %x, %p)\n", debugstr_w(lpszUrl),debugstr_w(lpszCookieName), lpCookieData, lpdwSize, flags, reserved); + + if (flags) + FIXME("flags 0x%08x not supported\n", flags); if (!lpszUrl) { @@ -659,15 +744,53 @@ return FALSE; } - res = get_cookie(host, path, lpCookieData, lpdwSize); - if(res != ERROR_SUCCESS) + EnterCriticalSection(&cookie_cs); + + res = get_cookie(host, path, flags, &cookie_set); + if(res != ERROR_SUCCESS) { + LeaveCriticalSection(&cookie_cs); SetLastError(res); - return res == ERROR_SUCCESS; -} - - -/*********************************************************************** - * InternetGetCookieA (WININET.@) + return FALSE; + } + + if(cookie_set.cnt) { + if(!lpCookieData || cookie_set.string_len+1 > *lpdwSize) { + *lpdwSize = (cookie_set.string_len + 1) * sizeof(WCHAR); + TRACE("returning %u\n", *lpdwSize); + if(lpCookieData) { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; + } + }else { + *lpdwSize = cookie_set.string_len + 1; + cookie_set_to_string(&cookie_set, lpCookieData); + lpCookieData[cookie_set.string_len] = 0; + } + }else { + TRACE("no cookies found for %s\n", debugstr_w(host)); + SetLastError(ERROR_NO_MORE_ITEMS); + ret = FALSE; + } + + heap_free(cookie_set.cookies); + LeaveCriticalSection(&cookie_cs); + return ret; +} + +/*********************************************************************** + * InternetGetCookieW (WININET.@) + * + * Retrieve cookie for the specified URL. + */ +BOOL WINAPI InternetGetCookieW(const WCHAR *url, const WCHAR *name, WCHAR *data, DWORD *size) +{ + TRACE("(%s, %s, %s, %p)\n", debugstr_w(url), debugstr_w(name), debugstr_w(data), size); + + return InternetGetCookieExW(url, name, data, size, 0, NULL); +} + +/*********************************************************************** + * InternetGetCookieExA (WININET.@) * * Retrieve cookie from the specified url * @@ -676,20 +799,20 @@ * FALSE on failure * */ -BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, - LPSTR lpCookieData, LPDWORD lpdwSize) +BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, + LPSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved) { WCHAR *url, *name; DWORD len, size; BOOL r; - TRACE("(%s %s %p %p(%u))\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName), - lpCookieData, lpdwSize, lpdwSize ? *lpdwSize : 0); + TRACE("(%s %s %p %p(%u) %x %p)\n", debugstr_a(lpszUrl), debugstr_a(lpszCookieName), + lpCookieData, lpdwSize, lpdwSize ? *lpdwSize : 0, flags, reserved); url = heap_strdupAtoW(lpszUrl); name = heap_strdupAtoW(lpszCookieName); - r = InternetGetCookieW( url, name, NULL, &len ); + r = InternetGetCookieExW( url, name, NULL, &len, flags, reserved ); if( r ) { WCHAR *szCookieData; @@ -701,7 +824,7 @@ } else { - r = InternetGetCookieW( url, name, szCookieData, &len ); + r = InternetGetCookieExW( url, name, szCookieData, &len, flags, reserved ); if(r) { size = WideCharToMultiByte( CP_ACP, 0, szCookieData, len, NULL, 0, NULL, NULL); @@ -724,6 +847,17 @@ return r; } +/*********************************************************************** + * InternetGetCookieA (WININET.@) + * + * See InternetGetCookieW. + */ +BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size) +{ + TRACE("(%s, %s, %s, %p)\n", debugstr_a(url), debugstr_a(name), debugstr_a(data), size); + + return InternetGetCookieExA(url, name, data, size, 0, NULL); +} /*********************************************************************** * IsDomainLegalCookieDomainW (WININET.@) @@ -761,22 +895,23 @@ return TRUE; } -BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWSTR cookie_data) -{ - cookie_domain *thisCookieDomain = NULL; - cookie *thisCookie; - struct list *cursor; +DWORD set_cookie(const WCHAR *domain, const WCHAR *path, const WCHAR *cookie_name, const WCHAR *cookie_data, DWORD flags) +{ + cookie_container_t *container; + cookie_t *thisCookie; LPWSTR data, value; WCHAR *ptr; FILETIME expiry, create; BOOL expired = FALSE, update_persistent = FALSE; - DWORD flags = 0; + DWORD cookie_flags = 0; + + TRACE("%s %s %s=%s %x\n", debugstr_w(domain), debugstr_w(path), debugstr_w(cookie_name), debugstr_w(cookie_data), flags); value = data = heap_strdupW(cookie_data); if (!data) { ERR("could not allocate the cookie data buffer\n"); - return FALSE; + return COOKIE_STATE_UNKNOWN; } memset(&expiry,0,sizeof(expiry)); @@ -802,7 +937,7 @@ { heap_free(data); ERR("could not allocate the cookie value buffer\n"); - return FALSE; + return COOKIE_STATE_UNKNOWN; } strcpyW(value, data); @@ -824,7 +959,7 @@ if(value != data) heap_free(value); heap_free(data); - return FALSE; + return COOKIE_STATE_UNKNOWN; } if(end_ptr) @@ -861,7 +996,15 @@ } else if (strncmpiW(ptr, szHttpOnly, 8) == 0) { - FIXME("httponly not handled (%s)\n",debugstr_w(ptr)); + if(!(flags & INTERNET_COOKIE_HTTPONLY)) { + WARN("HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n"); + heap_free(data); + if (value != data) heap_free(value); + SetLastError(ERROR_INVALID_OPERATION); + return COOKIE_STATE_REJECT; + } + + cookie_flags |= INTERNET_COOKIE_HTTPONLY; ptr += strlenW(szHttpOnly); } else if (*ptr) @@ -875,99 +1018,99 @@ load_persistent_cookie(domain, path); - LIST_FOR_EACH(cursor, &domain_list) - { - thisCookieDomain = LIST_ENTRY(cursor, cookie_domain, entry); - if (COOKIE_matchDomain(domain, path, thisCookieDomain, FALSE)) - break; - thisCookieDomain = NULL; - } - - if (!thisCookieDomain) - { - if (!expired) - thisCookieDomain = COOKIE_addDomain(domain, path); - else - { + container = get_cookie_container(domain, path, !expired); + if(!container) { + heap_free(data); + if (value != data) heap_free(value); + LeaveCriticalSection(&cookie_cs); + return COOKIE_STATE_ACCEPT; + } + + if(!expiry.dwLowDateTime && !expiry.dwHighDateTime) + cookie_flags |= INTERNET_COOKIE_IS_SESSION; + else + update_persistent = TRUE; + + if ((thisCookie = find_cookie(container, cookie_name))) + { + if ((thisCookie->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) { + WARN("An attempt to override httponly cookie\n"); + SetLastError(ERROR_INVALID_OPERATION); + heap_free(data); + if (value != data) heap_free(value); + return COOKIE_STATE_REJECT; + } + + if (!(thisCookie->flags & INTERNET_COOKIE_IS_SESSION)) + update_persistent = TRUE; + delete_cookie(thisCookie); + } + + TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_w(cookie_name), + debugstr_w(value), debugstr_w(container->domain->domain),debugstr_w(container->path)); + + if (!expired) { + cookie_t *new_cookie; + + new_cookie = alloc_cookie(cookie_name, value, expiry, create, cookie_flags); + if(!new_cookie) { heap_free(data); if (value != data) heap_free(value); LeaveCriticalSection(&cookie_cs); - return TRUE; - } - } - - if(!expiry.dwLowDateTime && !expiry.dwHighDateTime) - flags |= INTERNET_COOKIE_IS_SESSION; - else - update_persistent = TRUE; - - if ((thisCookie = COOKIE_findCookie(thisCookieDomain, cookie_name))) - { - if (!(thisCookie->flags & INTERNET_COOKIE_IS_SESSION)) - update_persistent = TRUE; - COOKIE_deleteCookie(thisCookie, FALSE); - } - - TRACE("setting cookie %s=%s for domain %s path %s\n", debugstr_w(cookie_name), - debugstr_w(value), debugstr_w(thisCookieDomain->lpCookieDomain),debugstr_w(thisCookieDomain->lpCookiePath)); - - if (!expired && !COOKIE_addCookie(thisCookieDomain, cookie_name, value, expiry, create, flags)) - { - heap_free(data); - if (value != data) heap_free(value); - LeaveCriticalSection(&cookie_cs); - return FALSE; + return COOKIE_STATE_UNKNOWN; + } + + add_cookie(container, new_cookie); } heap_free(data); if (value != data) heap_free(value); - if (!update_persistent || save_persistent_cookie(thisCookieDomain)) + if (!update_persistent || save_persistent_cookie(container)) { LeaveCriticalSection(&cookie_cs); - return TRUE; + return COOKIE_STATE_ACCEPT; } LeaveCriticalSection(&cookie_cs); - return FALSE; -} - -/*********************************************************************** - * InternetSetCookieW (WININET.@) + return COOKIE_STATE_UNKNOWN; +} + +/*********************************************************************** + * InternetSetCookieExW (WININET.@) * * Sets cookie for the specified url - * - * RETURNS - * TRUE on success - * FALSE on failure - * - */ -BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, - LPCWSTR lpCookieData) + */ +DWORD WINAPI InternetSetCookieExW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, + LPCWSTR lpCookieData, DWORD flags, DWORD_PTR reserved) { BOOL ret; WCHAR hostName[INTERNET_MAX_HOST_NAME_LENGTH], path[INTERNET_MAX_PATH_LENGTH]; - TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl), - debugstr_w(lpszCookieName), debugstr_w(lpCookieData)); + TRACE("(%s, %s, %s, %x, %lx)\n", debugstr_w(lpszUrl), debugstr_w(lpszCookieName), + debugstr_w(lpCookieData), flags, reserved); + + if (flags & ~INTERNET_COOKIE_HTTPONLY) + FIXME("flags %x not supported\n", flags); if (!lpszUrl || !lpCookieData) { SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; + return COOKIE_STATE_UNKNOWN; } hostName[0] = 0; ret = COOKIE_crackUrlSimple(lpszUrl, hostName, sizeof(hostName)/sizeof(hostName[0]), path, sizeof(path)/sizeof(path[0])); - if (!ret || !hostName[0]) return FALSE; + if (!ret || !hostName[0]) return COOKIE_STATE_UNKNOWN; if (!lpszCookieName) { WCHAR *cookie, *data; + DWORD res; cookie = heap_strdupW(lpCookieData); if (!cookie) { SetLastError(ERROR_OUTOFMEMORY); - return FALSE; + return COOKIE_STATE_UNKNOWN; } /* some apps (or is it us??) try to add a cookie with no cookie name, but @@ -976,14 +1119,25 @@ if (!(data = strchrW(cookie, '='))) data = cookie + strlenW(cookie); else *data++ = 0; - ret = set_cookie(hostName, path, cookie, data); + res = set_cookie(hostName, path, cookie, data, flags); heap_free(cookie); - return ret; - } - return set_cookie(hostName, path, lpszCookieName, lpCookieData); -} - + return res; + } + return set_cookie(hostName, path, lpszCookieName, lpCookieData, flags); +} + +/*********************************************************************** + * InternetSetCookieW (WININET.@) + * + * Sets a cookie for the specified URL. + */ +BOOL WINAPI InternetSetCookieW(const WCHAR *url, const WCHAR *name, const WCHAR *data) +{ + TRACE("(%s, %s, %s)\n", debugstr_w(url), debugstr_w(name), debugstr_w(data)); + + return InternetSetCookieExW(url, name, data, 0, 0) == COOKIE_STATE_ACCEPT; +} /*********************************************************************** * InternetSetCookieA (WININET.@) @@ -1024,111 +1178,63 @@ DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved) { - TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n", - debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData), - dwFlags, dwReserved); - - if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); - return InternetSetCookieA(lpszURL, lpszCookieName, lpszCookieData); -} - -/*********************************************************************** - * InternetSetCookieExW (WININET.@) - * - * Sets a cookie for the specified URL. + WCHAR *data, *url, *name; + DWORD r; + + TRACE("(%s, %s, %s, %x, %lx)\n", debugstr_a(lpszURL), debugstr_a(lpszCookieName), + debugstr_a(lpszCookieData), dwFlags, dwReserved); + + url = heap_strdupAtoW(lpszURL); + name = heap_strdupAtoW(lpszCookieName); + data = heap_strdupAtoW(lpszCookieData); + + r = InternetSetCookieExW(url, name, data, dwFlags, dwReserved); + + heap_free( data ); + heap_free( name ); + heap_free( url ); + return r; +} + +/*********************************************************************** + * InternetClearAllPerSiteCookieDecisions (WININET.@) + * + * Clears all per-site decisions about cookies. * * RETURNS * TRUE on success * FALSE on failure * */ -DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, - DWORD dwFlags, DWORD_PTR dwReserved) -{ - TRACE("(%s, %s, %s, 0x%08x, 0x%08lx)\n", - debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData), - dwFlags, dwReserved); - - if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); - return InternetSetCookieW(lpszURL, lpszCookieName, lpszCookieData); -} - -/*********************************************************************** - * InternetGetCookieExA (WININET.@) - * - * See InternetGetCookieExW. - */ -BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData, - LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved) -{ - TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n", - debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData), - pcchCookieData, dwFlags, lpReserved); - - if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); - return InternetGetCookieA(pchURL, pchCookieName, pchCookieData, pcchCookieData); -} - -/*********************************************************************** - * InternetGetCookieExW (WININET.@) - * - * Retrieve cookie for the specified URL. +BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID ) +{ + FIXME("stub\n"); + return TRUE; +} + +/*********************************************************************** + * InternetEnumPerSiteCookieDecisionA (WININET.@) + * + * See InternetEnumPerSiteCookieDecisionW. + */ +BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, ULONG *pcSiteNameSize, + ULONG *pdwDecision, ULONG dwIndex ) +{ + FIXME("(%s, %p, %p, 0x%08x) stub\n", + debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); + return FALSE; +} + +/*********************************************************************** + * InternetEnumPerSiteCookieDecisionW (WININET.@) + * + * Enumerates all per-site decisions about cookies. * * RETURNS * TRUE on success * FALSE on failure * */ -BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData, - LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved) -{ - TRACE("(%s, %s, %s, %p, 0x%08x, %p)\n", - debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData), - pcchCookieData, dwFlags, lpReserved); - - if (dwFlags) FIXME("flags 0x%08x not supported\n", dwFlags); - return InternetGetCookieW(pchURL, pchCookieName, pchCookieData, pcchCookieData); -} - -/*********************************************************************** - * InternetClearAllPerSiteCookieDecisions (WININET.@) - * - * Clears all per-site decisions about cookies. - * - * RETURNS - * TRUE on success - * FALSE on failure - * - */ -BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID ) -{ - FIXME("stub\n"); - return TRUE; -} - -/*********************************************************************** - * InternetEnumPerSiteCookieDecisionA (WININET.@) - * - * See InternetEnumPerSiteCookieDecisionW. - */ -BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, ULONG *pcSiteNameSize, - ULONG *pdwDecision, ULONG dwIndex ) -{ - FIXME("(%s, %p, %p, 0x%08x) stub\n", - debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex); - return FALSE; -} - -/*********************************************************************** - * InternetEnumPerSiteCookieDecisionW (WININET.@) - * - * Enumerates all per-site decisions about cookies. - * - * RETURNS - * TRUE on success - * FALSE on failure - * - */ BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, ULONG *pcSiteNameSize, ULONG *pdwDecision, ULONG dwIndex ) { Modified: trunk/reactos/dll/win32/wininet/ftp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/ftp.c?re…
============================================================================== --- trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/ftp.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -1153,7 +1153,7 @@ return ERROR_INTERNET_DISCONNECTED; /* FIXME: FTP should use NETCON_ stuff */ - res = recv(file->nDataSocket, buffer, size, MSG_WAITALL); + res = sock_recv(file->nDataSocket, buffer, size, MSG_WAITALL); *read = res>0 ? res : 0; error = res >= 0 ? ERROR_SUCCESS : INTERNET_ERROR_BASE; /* FIXME */ @@ -1178,7 +1178,7 @@ ftp_file_t *lpwh = (ftp_file_t*) hdr; int res; - res = send(lpwh->nDataSocket, buffer, size, 0); + res = sock_send(lpwh->nDataSocket, buffer, size, 0); *written = res>0 ? res : 0; return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno); @@ -1192,7 +1192,7 @@ TRACE("%p\n", file); - available = recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK); + available = sock_recv(file->nDataSocket, buffer, sizeof(buffer), MSG_PEEK); if(available != -1) { iar.dwResult = (DWORD_PTR)file->hdr.hInternet; @@ -1235,7 +1235,7 @@ *available = 0; - retval = recv(file->nDataSocket, &byte, 1, MSG_PEEK); + retval = sock_recv(file->nDataSocket, &byte, 1, MSG_PEEK); if(retval > 0) { task_header_t *task; @@ -2274,7 +2274,7 @@ TRACE("Sending (%s) len(%d)\n", cmd, len); while ((nBytesSent < len) && (nRC != -1)) { - nRC = send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0); + nRC = sock_send(lpwfs->sndSocket, cmd + nBytesSent, len - nBytesSent, 0); if (nRC != -1) { nBytesSent += nRC; @@ -2641,7 +2641,7 @@ TRACE("Sending (%s) len(%d)\n", buf, len); while((nBytesSent < len) && (nRC != -1)) { - nRC = send(nSocket, buf+nBytesSent, len - nBytesSent, 0); + nRC = sock_send(nSocket, buf+nBytesSent, len - nBytesSent, 0); nBytesSent += nRC; } heap_free(buf); @@ -3221,7 +3221,7 @@ nLen = DATA_PACKET_SIZE < nBytesToSend ? DATA_PACKET_SIZE : nBytesToSend; - nRC = send(nDataSocket, lpszBuffer, nLen, 0); + nRC = sock_send(nDataSocket, lpszBuffer, nLen, 0); if (nRC != -1) { @@ -3326,7 +3326,7 @@ while (nRC != -1) { - nRC = recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0); + nRC = sock_recv(nDataSocket, lpszBuffer, DATA_PACKET_SIZE, 0); if (nRC != -1) { /* other side closed socket. */ Modified: trunk/reactos/dll/win32/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/http.c?r…
============================================================================== --- trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -299,7 +299,11 @@ BOOL remaining = FALSE; DWORD64 now; +#ifdef __REACTOS__ now = GetTickCount(); +#else + now = GetTickCount64(); +#endif LIST_FOR_EACH_ENTRY_SAFE(server, server_safe, &connection_pool, server_t, entry) { LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) { @@ -740,7 +744,7 @@ continue; data++; - set_cookie(host->lpszValue, request->path, name, data); + set_cookie(host->lpszValue, request->path, name, data, INTERNET_COOKIE_HTTPONLY); heap_free(name); } } @@ -1300,7 +1304,7 @@ TRACE("%p, %s, %i, %i\n", hHttpRequest, debugstr_wn(lpszHeader, dwHeaderLength), dwHeaderLength, dwModifier); - if (!lpszHeader) + if (!lpszHeader) return TRUE; request = (http_request_t*) get_handle_object( hHttpRequest ); @@ -1951,7 +1955,7 @@ return; } #else - // silence unused function warning + /* Silence unused function warning */ (void)collect_connections_proc; #endif @@ -2859,10 +2863,11 @@ static DWORD set_content_length(http_request_t *request) { static const WCHAR szChunked[] = {'c','h','u','n','k','e','d',0}; + static const WCHAR headW[] = {'H','E','A','D',0}; WCHAR encoding[20]; DWORD size; - if(request->status_code == HTTP_STATUS_NO_CONTENT) { + if(request->status_code == HTTP_STATUS_NO_CONTENT || !strcmpW(request->verb, headW)) { request->contentLength = request->netconn_stream.content_length = 0; return ERROR_SUCCESS; } @@ -3345,9 +3350,6 @@ request->version = heap_strdupW(lpszVersion && *lpszVersion ? lpszVersion : g_szHttp1_1); HTTP_ProcessHeader(request, hostW, request->server->canon_host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); - - if (session->hostPort == INTERNET_INVALID_PORT_NUMBER) - session->hostPort = INTERNET_DEFAULT_HTTP_PORT; if (hIC->proxy && hIC->proxy[0] && !HTTP_ShouldBypassProxy(hIC, session->hostName)) HTTP_DealWithProxy( hIC, session, request ); @@ -3673,8 +3675,6 @@ return ERROR_HTTP_HEADER_NOT_FOUND; } - if (lpdwIndex) (*lpdwIndex)++; - /* coalesce value to requested type */ if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER && lpBuffer) { @@ -3720,6 +3720,7 @@ } *lpdwBufferLength = len - sizeof(WCHAR); } + if (lpdwIndex) (*lpdwIndex)++; return ERROR_SUCCESS; } @@ -3842,13 +3843,13 @@ info_mod &= ~ modifier_flags[i].val; } } - + if (info_mod) { TRACE(" Unknown (%08x)", info_mod); } TRACE("\n"); } - + request = (http_request_t*) get_handle_object( hHttpRequest ); if (NULL == request || request->hdr.htype != WH_HHTTPREQ) { @@ -3955,9 +3956,9 @@ urlComponents.dwStructSize = sizeof(URL_COMPONENTSW); urlComponents.lpszScheme = (request->hdr.dwFlags & INTERNET_FLAG_SECURE) ? szHttps : szHttp; urlComponents.dwSchemeLength = 0; - urlComponents.lpszHostName = session->hostName; + urlComponents.lpszHostName = request->server->name; urlComponents.dwHostNameLength = 0; - urlComponents.nPort = session->hostPort; + urlComponents.nPort = request->server->port; urlComponents.lpszUserName = session->userName; urlComponents.dwUserNameLength = 0; urlComponents.lpszPassword = NULL; @@ -4082,6 +4083,7 @@ } else session->hostName = heap_strdupW(hostName); + session->hostPort = urlComponents.nPort; HTTP_ProcessHeader(request, hostW, session->hostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); @@ -4154,68 +4156,17 @@ return str; } -static DWORD HTTP_SecureProxyConnect(http_request_t *request) -{ - server_t *server = request->server; - LPWSTR requestString; - INT len; - INT cnt; - INT responseLen; - char *ascii_req; +static void HTTP_InsertCookies(http_request_t *request) +{ + WCHAR *cookies; DWORD res; - static const WCHAR connectW[] = {'C','O','N','N','E','C','T',0}; - - TRACE("\n"); - - requestString = build_request_header( request, connectW, server->host_port, g_szHttp1_1, TRUE ); - - len = WideCharToMultiByte( CP_ACP, 0, requestString, -1, - NULL, 0, NULL, NULL ); - len--; /* the nul terminator isn't needed */ - ascii_req = heap_alloc(len); - WideCharToMultiByte( CP_ACP, 0, requestString, -1, ascii_req, len, NULL, NULL ); - heap_free( requestString ); - - TRACE("full request -> %s\n", debugstr_an( ascii_req, len ) ); - - NETCON_set_timeout( request->netconn, TRUE, request->send_timeout ); - res = NETCON_send( request->netconn, ascii_req, len, 0, &cnt ); - heap_free( ascii_req ); - if (res != ERROR_SUCCESS) - return res; - - if (HTTP_GetResponseHeaders( request, &responseLen ) || !responseLen) - return ERROR_HTTP_INVALID_HEADER; - - return ERROR_SUCCESS; -} - -static void HTTP_InsertCookies(http_request_t *request) -{ - DWORD cookie_size, size, cnt = 0; - HTTPHEADERW *host; - WCHAR *cookies; - - static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' ',0}; - - host = HTTP_GetHeader(request, hostW); - if(!host) + res = get_cookie_header(request->server->name, request->path, &cookies); + if(res != ERROR_SUCCESS || !cookies) return; - if(get_cookie(host->lpszValue, request->path, NULL, &cookie_size) != ERROR_SUCCESS) - return; - - size = sizeof(cookieW) + cookie_size * sizeof(WCHAR) + sizeof(szCrLf); - if(!(cookies = heap_alloc(size))) - return; - - cnt += sprintfW(cookies, cookieW); - get_cookie(host->lpszValue, request->path, cookies+cnt, &cookie_size); - strcatW(cookies, szCrLf); - + get_cookie_header(request->server->name, request->path, &cookies); HTTP_HttpAddRequestHeadersW(request, cookies, strlenW(cookies), HTTP_ADDREQ_FLAG_REPLACE); - heap_free(cookies); } @@ -4815,27 +4766,22 @@ INTERNET_STATUS_CONNECTED_TO_SERVER, request->server->addr_str, strlen(request->server->addr_str)+1); - if(is_https) { - /* Note: we differ from Microsoft's WinINet here. they seem to have - * a bug that causes no status callbacks to be sent when starting - * a tunnel to a proxy server using the CONNECT verb. i believe our - * behaviour to be more correct and to not cause any incompatibilities - * because using a secure connection through a proxy server is a rare - * case that would be hard for anyone to depend on */ - if(request->proxy) - res = HTTP_SecureProxyConnect(request); - if(res == ERROR_SUCCESS) - res = NETCON_secure_connect(request->netconn, request->server); - } - - if(res != ERROR_SUCCESS) { - http_release_netconn(request, FALSE); - return res; - } - *reusing = FALSE; TRACE("Created connection to %s: %p\n", debugstr_w(request->server->name), netconn); return ERROR_SUCCESS; +} + +static char *build_ascii_request( const WCHAR *str, void *data, DWORD data_len, DWORD *out_len ) +{ + int len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); + char *ret; + + if (!(ret = heap_alloc( len + data_len ))) return NULL; + WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + if (data_len) memcpy( ret + len - 1, data, data_len ); + *out_len = len + data_len - 1; + ret[*out_len] = 0; + return ret; } /*********************************************************************** @@ -4852,13 +4798,11 @@ DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength, DWORD dwContentLength, BOOL bEndRequest) { - INT cnt; - BOOL redirected = FALSE; - LPWSTR requestString = NULL; - INT responseLen; - BOOL loop_next; static const WCHAR szContentLength[] = { 'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','l','i','\r','\n',0 }; + BOOL redirected = FALSE, secure_proxy_connect = FALSE, loop_next; + LPWSTR requestString = NULL; + INT responseLen, cnt; WCHAR contentLengthStr[sizeof szContentLength/2 /* includes \r\n */ + 20 /* int */ ]; DWORD res; @@ -4873,7 +4817,7 @@ if (dwContentLength || strcmpW(request->verb, szGET)) { sprintfW(contentLengthStr, szContentLength, dwContentLength); - HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_REPLACE); + HTTP_HttpAddRequestHeadersW(request, contentLengthStr, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW); request->bytesToWrite = dwContentLength; } if (request->session->appInfo->agent) @@ -4907,7 +4851,7 @@ do { - DWORD len; + DWORD len, data_len = dwOptionalLength; BOOL reusing_connection; char *ascii_req; @@ -4935,7 +4879,31 @@ if (!(request->hdr.dwFlags & INTERNET_FLAG_NO_COOKIES)) HTTP_InsertCookies(request); - if (request->proxy) + res = open_http_connection(request, &reusing_connection); + if (res != ERROR_SUCCESS) + break; + + if (!reusing_connection && (request->hdr.dwFlags & INTERNET_FLAG_SECURE)) + { + if (request->proxy) secure_proxy_connect = TRUE; + else + { + res = NETCON_secure_connect(request->netconn, request->server); + if (res != ERROR_SUCCESS) + { + WARN("failed to upgrade to secure connection\n"); + http_release_netconn(request, FALSE); + break; + } + } + } + if (secure_proxy_connect) + { + static const WCHAR connectW[] = {'C','O','N','N','E','C','T',0}; + const WCHAR *target = request->server->host_port; + requestString = build_request_header(request, connectW, target, g_szHttp1_1, TRUE); + } + else if (request->proxy && !(request->hdr.dwFlags & INTERNET_FLAG_SECURE)) { WCHAR *url = build_proxy_path_url(request); requestString = build_request_header(request, request->verb, url, request->version, TRUE); @@ -4944,25 +4912,13 @@ else requestString = build_request_header(request, request->verb, request->path, request->version, TRUE); - TRACE("Request header -> %s\n", debugstr_w(requestString) ); - res = open_http_connection(request, &reusing_connection); - if (res != ERROR_SUCCESS) - break; - /* send the request as ASCII, tack on the optional data */ - if (!lpOptional || redirected) - dwOptionalLength = 0; - len = WideCharToMultiByte( CP_ACP, 0, requestString, -1, - NULL, 0, NULL, NULL ); - ascii_req = heap_alloc(len + dwOptionalLength); - WideCharToMultiByte( CP_ACP, 0, requestString, -1, - ascii_req, len, NULL, NULL ); - if( lpOptional ) - memcpy( &ascii_req[len-1], lpOptional, dwOptionalLength ); - len = (len + dwOptionalLength - 1); - ascii_req[len] = 0; + if (!lpOptional || redirected || secure_proxy_connect) + data_len = 0; + + ascii_req = build_ascii_request( requestString, lpOptional, data_len, &len ); TRACE("full request -> %s\n", debugstr_a(ascii_req) ); INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, @@ -4980,7 +4936,7 @@ continue; } - request->bytesWritten = dwOptionalLength; + request->bytesWritten = data_len; INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, @@ -4992,7 +4948,7 @@ INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0); - + if (HTTP_GetResponseHeaders(request, &responseLen)) { http_release_netconn(request, FALSE); @@ -5117,6 +5073,25 @@ } } } + if (secure_proxy_connect && request->status_code == HTTP_STATUS_OK) + { + int index; + + res = NETCON_secure_connect(request->netconn, request->server); + if (res != ERROR_SUCCESS) + { + WARN("failed to upgrade to secure proxy connection\n"); + http_release_netconn( request, FALSE ); + break; + } + index = HTTP_GetCustomHeaderIndex(request, szProxy_Authorization, 0, TRUE); + if (index != -1) HTTP_DeleteCustomHeader(request, index); + destroy_authinfo(request->proxyAuthInfo); + request->proxyAuthInfo = NULL; + + secure_proxy_connect = FALSE; + loop_next = TRUE; + } } else res = ERROR_SUCCESS; @@ -6039,7 +6014,7 @@ /* REPLACE wins out over ADD */ if (dwModifier & HTTP_ADDHDR_FLAG_REPLACE) dwModifier &= ~HTTP_ADDHDR_FLAG_ADD; - + if (dwModifier & HTTP_ADDHDR_FLAG_ADD) index = -1; else Modified: trunk/reactos/dll/win32/wininet/internet.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/internet…
============================================================================== --- trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/internet.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -57,6 +57,8 @@ DWORD proxyEnabled; LPWSTR proxy; LPWSTR proxyBypass; + LPWSTR proxyUsername; + LPWSTR proxyPassword; } proxyinfo_t; static ULONG max_conns = 2, max_1_0_conns = 4; @@ -245,9 +247,11 @@ if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES) return FALSE; -#ifndef __REACTOS__ - URLCacheContainers_CreateDefaults(); -#endif + if(!init_urlcache()) + { + TlsFree(g_dwTlsErrIndex); + return FALSE; + } WININET_hModule = hinstDLL; break; @@ -277,6 +281,15 @@ break; } return TRUE; +} + +/*********************************************************************** + * DllInstall (WININET.@) + */ +HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline) +{ + FIXME("(%x %s): stub\n", bInstall, debugstr_w(cmdline)); + return S_OK; } /*********************************************************************** @@ -454,6 +467,8 @@ { heap_free(lpwpi->proxy); heap_free(lpwpi->proxyBypass); + heap_free(lpwpi->proxyUsername); + heap_free(lpwpi->proxyPassword); } static proxyinfo_t *global_proxy; @@ -467,6 +482,50 @@ heap_free( global_proxy ); } LeaveCriticalSection( &WININET_cs ); +} + +static BOOL parse_proxy_url( proxyinfo_t *info, const WCHAR *url ) +{ + static const WCHAR fmt[] = {'%','s',':','%','u',0}; + WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH] = {0}; + WCHAR username[INTERNET_MAX_USER_NAME_LENGTH] = {0}; + WCHAR password[INTERNET_MAX_PASSWORD_LENGTH] = {0}; + URL_COMPONENTSW uc; + + memset( &uc, 0, sizeof(uc) ); + uc.dwStructSize = sizeof(uc); + uc.lpszHostName = hostname; + uc.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH; + uc.lpszUserName = username; + uc.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH; + uc.lpszPassword = password; + uc.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH; + + if (!InternetCrackUrlW( url, 0, 0, &uc )) return FALSE; + if (!hostname[0]) + { + if (!(info->proxy = heap_strdupW( url ))) return FALSE; + info->proxyUsername = NULL; + info->proxyPassword = NULL; + return TRUE; + } + if (!(info->proxy = heap_alloc( (strlenW(hostname) + 12) * sizeof(WCHAR) ))) return FALSE; + sprintfW( info->proxy, fmt, hostname, uc.nPort ); + + if (!username[0]) info->proxyUsername = NULL; + else if (!(info->proxyUsername = heap_strdupW( username ))) + { + heap_free( info->proxy ); + return FALSE; + } + if (!password[0]) info->proxyPassword = NULL; + else if (!(info->proxyPassword = heap_strdupW( password ))) + { + heap_free( info->proxyUsername ); + heap_free( info->proxy ); + return FALSE; + } + return TRUE; } /*********************************************************************** @@ -488,6 +547,8 @@ LPCSTR envproxy; LONG ret; + memset( lpwpi, 0, sizeof(*lpwpi) ); + EnterCriticalSection( &WININET_cs ); if (global_proxy) { @@ -498,7 +559,10 @@ LeaveCriticalSection( &WININET_cs ); if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key ))) + { + FreeProxyInfo( lpwpi ); return ret; + } len = sizeof(DWORD); if (RegQueryValueExW( key, szProxyEnable, NULL, &type, (BYTE *)&lpwpi->proxyEnabled, &len ) || type != REG_DWORD) @@ -506,6 +570,7 @@ lpwpi->proxyEnabled = 0; if((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE *)&lpwpi->proxyEnabled, sizeof(DWORD) ))) { + FreeProxyInfo( lpwpi ); RegCloseKey( key ); return ret; } @@ -513,8 +578,6 @@ if (!(envproxy = getenv( "http_proxy" )) || lpwpi->proxyEnabled) { - TRACE("Proxy is enabled.\n"); - /* figure out how much memory the proxy setting takes */ if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ)) { @@ -524,6 +587,7 @@ if (!(szProxy = heap_alloc(len))) { RegCloseKey( key ); + FreeProxyInfo( lpwpi ); return ERROR_OUTOFMEMORY; } RegQueryValueExW( key, szProxyServer, NULL, &type, (BYTE*)szProxy, &len ); @@ -535,17 +599,21 @@ p += lstrlenW( szHttp ); lstrcpyW( szProxy, p ); } - p = strchrW( szProxy, ' ' ); + p = strchrW( szProxy, ';' ); if (p) *p = 0; + FreeProxyInfo( lpwpi ); lpwpi->proxy = szProxy; - - TRACE("http proxy = %s\n", debugstr_w(lpwpi->proxy)); + lpwpi->proxyBypass = NULL; + + TRACE("http proxy (from registry) = %s\n", debugstr_w(lpwpi->proxy)); } else { TRACE("No proxy server settings in registry.\n"); + FreeProxyInfo( lpwpi ); lpwpi->proxy = NULL; + lpwpi->proxyBypass = NULL; } } else if (envproxy) @@ -554,18 +622,33 @@ len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 ); if (!(envproxyW = heap_alloc(len * sizeof(WCHAR)))) + { + RegCloseKey( key ); return ERROR_OUTOFMEMORY; + } MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len ); - lpwpi->proxyEnabled = 1; - lpwpi->proxy = envproxyW; - - TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->proxy)); - } - - lpwpi->proxyBypass = NULL; + FreeProxyInfo( lpwpi ); + if (parse_proxy_url( lpwpi, envproxyW )) + { + TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->proxy)); + lpwpi->proxyEnabled = 1; + lpwpi->proxyBypass = NULL; + } + else + { + WARN("failed to parse http_proxy value %s\n", debugstr_w(envproxyW)); + lpwpi->proxyEnabled = 0; + lpwpi->proxy = NULL; + lpwpi->proxyBypass = NULL; + } + heap_free( envproxyW ); + } + if (lpwpi->proxyEnabled) { + TRACE("Proxy is enabled.\n"); + if (!(envproxy = getenv( "no_proxy" ))) { /* figure out how much memory the proxy setting takes */ @@ -580,32 +663,40 @@ } RegQueryValueExW( key, szProxyOverride, NULL, &type, (BYTE*)szProxy, &len ); + heap_free( lpwpi->proxyBypass ); lpwpi->proxyBypass = szProxy; - TRACE("http proxy bypass = %s\n", debugstr_w(lpwpi->proxyBypass)); + TRACE("http proxy bypass (from registry) = %s\n", debugstr_w(lpwpi->proxyBypass)); } else { + heap_free( lpwpi->proxyBypass ); + lpwpi->proxyBypass = NULL; + TRACE("No proxy bypass server settings in registry.\n"); } } - else if (envproxy) + else { WCHAR *envproxyW; len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 ); if (!(envproxyW = heap_alloc(len * sizeof(WCHAR)))) + { + RegCloseKey( key ); return ERROR_OUTOFMEMORY; + } MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len ); + heap_free( lpwpi->proxyBypass ); lpwpi->proxyBypass = envproxyW; TRACE("http proxy bypass (from environment) = %s\n", debugstr_w(lpwpi->proxyBypass)); } } + else TRACE("Proxy is disabled.\n"); RegCloseKey( key ); - return ERROR_SUCCESS; } @@ -614,56 +705,21 @@ */ static BOOL INTERNET_ConfigureProxy( appinfo_t *lpwai ) { - proxyinfo_t wpi = {0}; + proxyinfo_t wpi; if (INTERNET_LoadProxySettings( &wpi )) return FALSE; if (wpi.proxyEnabled) { - WCHAR proxyurl[INTERNET_MAX_URL_LENGTH]; - WCHAR username[INTERNET_MAX_USER_NAME_LENGTH]; - WCHAR password[INTERNET_MAX_PASSWORD_LENGTH]; - WCHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH]; - URL_COMPONENTSW UrlComponents; - - UrlComponents.dwStructSize = sizeof UrlComponents; - UrlComponents.dwSchemeLength = 0; - UrlComponents.lpszHostName = hostname; - UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH; - UrlComponents.lpszUserName = username; - UrlComponents.dwUserNameLength = INTERNET_MAX_USER_NAME_LENGTH; - UrlComponents.lpszPassword = password; - UrlComponents.dwPasswordLength = INTERNET_MAX_PASSWORD_LENGTH; - UrlComponents.dwUrlPathLength = 0; - UrlComponents.dwExtraInfoLength = 0; - - if(InternetCrackUrlW(wpi.proxy, 0, 0, &UrlComponents)) - { - static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',':','%','u',0 }; - - if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) - UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT; - sprintfW(proxyurl, szFormat, hostname, UrlComponents.nPort); - - lpwai->accessType = INTERNET_OPEN_TYPE_PROXY; - lpwai->proxy = heap_strdupW(proxyurl); - lpwai->proxyBypass = heap_strdupW(wpi.proxyBypass); - if (UrlComponents.dwUserNameLength) - { - lpwai->proxyUsername = heap_strdupW(UrlComponents.lpszUserName); - lpwai->proxyPassword = heap_strdupW(UrlComponents.lpszPassword); - } - - TRACE("http proxy = %s bypass = %s\n", debugstr_w(lpwai->proxy), debugstr_w(lpwai->proxyBypass)); - FreeProxyInfo(&wpi); - return TRUE; - } - else - { - TRACE("Failed to parse proxy: %s\n", debugstr_w(wpi.proxy)); - lpwai->proxy = NULL; - } + TRACE("http proxy = %s bypass = %s\n", debugstr_w(lpwai->proxy), debugstr_w(lpwai->proxyBypass)); + + lpwai->accessType = INTERNET_OPEN_TYPE_PROXY; + lpwai->proxy = wpi.proxy; + lpwai->proxyBypass = wpi.proxyBypass; + lpwai->proxyUsername = wpi.proxyUsername; + lpwai->proxyPassword = wpi.proxyPassword; + return TRUE; } lpwai->accessType = INTERNET_OPEN_TYPE_DIRECT; @@ -1198,11 +1254,10 @@ rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen, dwReserved); if (rc && lpwszConnectionName) - { WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName, dwNameLen, NULL, NULL); - heap_free(lpwszConnectionName); - } + + heap_free(lpwszConnectionName); return rc; } @@ -2008,7 +2063,7 @@ { HRESULT hr; - TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer, + TRACE("(%s, %p, %p, 0x%08x) buffer length: %d\n", debugstr_a(lpszUrl), lpszBuffer, lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1); dwFlags = convert_url_canonicalization_flags(dwFlags); @@ -2034,7 +2089,7 @@ { HRESULT hr; - TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer, + TRACE("(%s, %p, %p, 0x%08x) buffer length: %d\n", debugstr_w(lpszUrl), lpszBuffer, lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1); dwFlags = convert_url_canonicalization_flags(dwFlags); @@ -2302,6 +2357,34 @@ return res == ERROR_SUCCESS; } +static BOOL get_proxy_autoconfig_url( char *buf, DWORD buflen ) +{ +#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + + CFDictionaryRef settings = CFNetworkCopySystemProxySettings(); + const void *ref; + BOOL ret = FALSE; + + if (!settings) return FALSE; + + if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString ))) + { + CFRelease( settings ); + return FALSE; + } + if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII )) + { + TRACE( "returning %s\n", debugstr_a(buf) ); + ret = TRUE; + } + CFRelease( settings ); + return ret; +#else + FIXME( "no support on this platform\n" ); + return FALSE; +#endif +} + static DWORD query_global_option(DWORD option, void *buffer, DWORD *size, BOOL unicode) { /* FIXME: This function currently handles more options than it should. Options requiring @@ -2385,15 +2468,19 @@ } case INTERNET_OPTION_PER_CONNECTION_OPTION: { + char url[INTERNET_MAX_URL_LENGTH + 1]; INTERNET_PER_CONN_OPTION_LISTW *con = buffer; INTERNET_PER_CONN_OPTION_LISTA *conA = buffer; DWORD res = ERROR_SUCCESS, i; proxyinfo_t pi; + BOOL have_url; LONG ret; TRACE("Getting global proxy info\n"); if((ret = INTERNET_LoadProxySettings(&pi))) return ret; + + have_url = get_proxy_autoconfig_url(url, sizeof(url)); FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n"); @@ -2412,6 +2499,9 @@ optionW->Value.dwValue = PROXY_TYPE_PROXY; else optionW->Value.dwValue = PROXY_TYPE_DIRECT; + if (have_url) + /* native includes PROXY_TYPE_DIRECT even if PROXY_TYPE_PROXY is set */ + optionW->Value.dwValue |= PROXY_TYPE_DIRECT|PROXY_TYPE_AUTO_PROXY_URL; break; case INTERNET_PER_CONN_PROXY_SERVER: @@ -2429,7 +2519,18 @@ break; case INTERNET_PER_CONN_AUTOCONFIG_URL: + if (!have_url) + optionW->Value.pszValue = NULL; + else if (unicode) + optionW->Value.pszValue = heap_strdupAtoW(url); + else + optionA->Value.pszValue = heap_strdupA(url); + break; + case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: + optionW->Value.dwValue = AUTO_PROXY_FLAG_ALWAYS_DETECT; + break; + case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL: case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS: case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME: @@ -2848,7 +2949,7 @@ unsigned int i; proxyinfo_t pi; - INTERNET_LoadProxySettings(&pi); + if (INTERNET_LoadProxySettings(&pi)) return FALSE; for (i = 0; i < con->dwOptionCount; i++) { INTERNET_PER_CONN_OPTIONW *option = con->pOptions + i; @@ -3772,7 +3873,7 @@ LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen) { - // ReactOS: use select instead of poll + /* ReactOS: use select instead of poll */ fd_set infd; struct timeval tv; BOOL bSuccess = FALSE; @@ -3790,7 +3891,7 @@ { if (select(0, &infd, NULL, NULL, &tv) > 0) { - if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0) + if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0) { INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS); goto lend; Modified: trunk/reactos/dll/win32/wininet/internet.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/internet…
============================================================================== --- trunk/reactos/dll/win32/wininet/internet.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/internet.h [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -458,8 +458,8 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort, struct sockaddr *psa, socklen_t *sa_len) DECLSPEC_HIDDEN; -DWORD get_cookie(const WCHAR*,const WCHAR*,WCHAR*,DWORD*) DECLSPEC_HIDDEN; -BOOL set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN; +DWORD get_cookie_header(const WCHAR*,const WCHAR*,WCHAR**) DECLSPEC_HIDDEN; +DWORD set_cookie(const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*,DWORD) DECLSPEC_HIDDEN; void INTERNET_SetLastError(DWORD dwError) DECLSPEC_HIDDEN; DWORD INTERNET_GetLastError(void) DECLSPEC_HIDDEN; @@ -497,6 +497,7 @@ #ifndef __REACTOS__ int sock_get_error(int) DECLSPEC_HIDDEN; #else + #define sock_get_error(x) WSAGetLastError() const char *inet_ntop(int, const void *, char *, socklen_t); @@ -517,7 +518,11 @@ return getsockopt(socket, level, option_name, option_value, option_len); } #define getsockopt unix_getsockopt -#endif + +#endif /* !__REACTOS__ */ + +int sock_send(int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN; +int sock_recv(int fd, void *msg, size_t len, int flags) DECLSPEC_HIDDEN; server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL); Modified: trunk/reactos/dll/win32/wininet/netconnection.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/netconne…
============================================================================== --- trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/netconnection.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -267,7 +267,7 @@ if(result == -1) { if (sock_get_error(errno) == WSAEINPROGRESS) { - // ReactOS: use select instead of poll + /* ReactOS: use select instead of poll */ fd_set outfd; struct timeval tv; int res; @@ -280,6 +280,7 @@ if (!res) { closesocket(netconn->socket); + netconn->socket = -1; return ERROR_INTERNET_CANNOT_CONNECT; } else if (res > 0) @@ -449,7 +450,29 @@ #endif return err; } -#endif +#endif /* !__REACTOS__ */ + +int sock_send(int fd, const void *msg, size_t len, int flags) +{ + int ret; + do + { + ret = send(fd, msg, len, flags); + } + while(ret == -1 && errno == EINTR); + return ret; +} + +int sock_recv(int fd, void *msg, size_t len, int flags) +{ + int ret; + do + { + ret = recv(fd, msg, len, flags); + } + while(ret == -1 && errno == EINTR); + return ret; +} static void set_socket_blocking(int socket, blocking_mode_t mode) { @@ -501,7 +524,7 @@ TRACE("sending %u bytes\n", out_buf.cbBuffer); - size = send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); + size = sock_send(connection->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); if(size != out_buf.cbBuffer) { ERR("send failed\n"); status = ERROR_INTERNET_SECURITY_CHANNEL_ERROR; @@ -540,7 +563,7 @@ read_buf_size += 1024; } - size = recv(connection->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0); + size = sock_recv(connection->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0); if(size < 1) { WARN("recv error\n"); res = ERROR_INTERNET_SECURITY_CHANNEL_ERROR; @@ -591,6 +614,8 @@ } } + heap_free(read_buf); + if(status != SEC_E_OK || res != ERROR_SUCCESS) { WARN("Failed to establish SSL connection: %08x (%u)\n", status, res); heap_free(connection->ssl_buf); @@ -671,7 +696,7 @@ return FALSE; } - if(send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) { + if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) { WARN("send failed\n"); return FALSE; } @@ -689,7 +714,7 @@ { if(!connection->secure) { - *sent = send(connection->socket, msg, len, flags); + *sent = sock_send(connection->socket, msg, len, flags); if (*sent == -1) return sock_get_error(errno); return ERROR_SUCCESS; @@ -741,7 +766,7 @@ tmp_mode = buf_len ? BLOCKING_DISALLOW : mode; set_socket_blocking(conn->socket, tmp_mode); - size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, tmp_mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT); + size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, tmp_mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT); if(size < 0) { if(!buf_len) { if(errno == EAGAIN || errno == EWOULDBLOCK) { @@ -782,7 +807,7 @@ assert(buf_len < ssl_buf_size); set_socket_blocking(conn->socket, mode); - size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT); + size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, mode == BLOCKING_ALLOW ? 0 : WINE_MSG_DONTWAIT); if(size < 1) { if(size < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) { TRACE("would block\n"); @@ -866,7 +891,7 @@ } set_socket_blocking(connection->socket, mode); - *recvd = recv(connection->socket, buf, len, flags); + *recvd = sock_recv(connection->socket, buf, len, flags); return *recvd == -1 ? sock_get_error(errno) : ERROR_SUCCESS; } else @@ -954,7 +979,7 @@ ssize_t len; BYTE b; - len = recv(netconn->socket, &b, 1, MSG_PEEK|MSG_DONTWAIT); + len = sock_recv(netconn->socket, &b, 1, MSG_PEEK|MSG_DONTWAIT); return len == 1 || (len == -1 && errno == EWOULDBLOCK); #elif defined(__MINGW32__) || defined(_MSC_VER) ULONG mode; @@ -965,7 +990,7 @@ if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) return FALSE; - len = recv(netconn->socket, &b, 1, MSG_PEEK); + len = sock_recv(netconn->socket, &b, 1, MSG_PEEK); mode = 0; if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) Modified: trunk/reactos/dll/win32/wininet/urlcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/urlcache…
============================================================================== --- trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -179,7 +179,7 @@ /* List of all containers available */ static struct list UrlContainers = LIST_INIT(UrlContainers); -// ReactOS r54992 +/* ReactOS r54992 */ BOOL bDefaultContainersAdded = FALSE; static inline char *heap_strdupWtoUTF8(LPCWSTR str) @@ -731,7 +731,7 @@ static const WCHAR UrlSuffix[] = {'C','o','n','t','e','n','t','.','I','E','5',0}; static const WCHAR HistorySuffix[] = {'H','i','s','t','o','r','y','.','I','E','5',0}; static const WCHAR CookieSuffix[] = {0}; - // ReactOS r50916 + /* ReactOS r50916 */ static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0}; static const struct { @@ -747,7 +747,7 @@ }; DWORD i; - // ReactOS r50916 + /* ReactOS r50916 */ if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) { TRACE("Environment variable 'USERPROFILE' does not exist!\n"); @@ -823,7 +823,7 @@ if(!url) return ERROR_INVALID_PARAMETER; - // ReactOS r54992 + /* ReactOS r54992 */ if (!bDefaultContainersAdded) cache_containers_init(); @@ -853,7 +853,7 @@ if (search_pattern && index > 0) return FALSE; - // ReactOS r54992 + /* ReactOS r54992 */ if (!bDefaultContainersAdded) cache_containers_init(); @@ -1477,7 +1477,7 @@ for (i = 0; i < sizeof(key) / sizeof(key[0]); i++) key[i] = lookupTable[(*lpszKey + i) & 0xFF]; - for (lpszKey++; *lpszKey && ((lpszKey[0] != '/') || (lpszKey[1] != 0)); lpszKey++) + for (lpszKey++; *lpszKey; lpszKey++) { for (i = 0; i < sizeof(key) / sizeof(key[0]); i++) key[i] = lookupTable[*lpszKey ^ key[i]]; Removed: trunk/reactos/dll/win32/wininet/wininet_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/wininet_…
============================================================================== --- trunk/reactos/dll/win32/wininet/wininet_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/wininet_main.c (removed) @@ -1,32 +0,0 @@ -/* - * WinInet - * - * Copyright (c) 2000 Patrik Stridvall - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "internet.h" - -/*********************************************************************** - * DllInstall (WININET.@) - */ -HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline) -{ - FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", - debugstr_w(cmdline)); - - return S_OK; -} Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Sep 25 15:31:21 2014 @@ -211,7 +211,7 @@ reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.17 reactos/dll/win32/wing32 # Out of sync reactos/dll/win32/winhttp # Synced to Wine-1.7.27 -reactos/dll/win32/wininet # Synced to Wine-1.7.17 +reactos/dll/win32/wininet # Synced to Wine-1.7.27 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628
10 years, 3 months
1
0
0
0
[akhaldi] 64275: [PSDK] * Add InternetCookieState and INTERNET_COOKIE_HTTPONLY. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:22:04 2014 New Revision: 64275 URL:
http://svn.reactos.org/svn/reactos?rev=64275&view=rev
Log: [PSDK] * Add InternetCookieState and INTERNET_COOKIE_HTTPONLY. CORE-8540 Modified: trunk/reactos/include/psdk/wininet.h Modified: trunk/reactos/include/psdk/wininet.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/wininet.h?rev…
============================================================================== --- trunk/reactos/include/psdk/wininet.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/wininet.h [iso-8859-1] Thu Sep 25 15:22:04 2014 @@ -1786,6 +1786,16 @@ #define HttpQueryInfo WINELIB_NAME_AW(HttpQueryInfo) +typedef enum { + COOKIE_STATE_UNKNOWN, + COOKIE_STATE_ACCEPT, + COOKIE_STATE_PROMPT, + COOKIE_STATE_LEASH, + COOKIE_STATE_DOWNGRADE, + COOKIE_STATE_REJECT, + COOKIE_STATE_MAX = COOKIE_STATE_REJECT +} InternetCookieState; + BOOLAPI InternetClearAllPerSiteCookieDecisions(VOID); BOOLAPI @@ -1814,6 +1824,7 @@ #define INTERNET_COOKIE_IS_RESTRICTED 0x00000200 #define INTERNET_COOKIE_IE6 0x00000400 #define INTERNET_COOKIE_IS_LEGACY 0x00000800 +#define INTERNET_COOKIE_HTTPONLY 0x00002000 BOOLAPI InternetGetCookieExA(
10 years, 3 months
1
0
0
0
[akhaldi] 64274: [WINHTTP_WINETEST] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:10:35 2014 New Revision: 64274 URL:
http://svn.reactos.org/svn/reactos?rev=64274&view=rev
Log: [WINHTTP_WINETEST] * Sync with Wine 1.7.27. CORE-8540 Modified: trunk/rostests/winetests/winhttp/url.c trunk/rostests/winetests/winhttp/winhttp.c Modified: trunk/rostests/winetests/winhttp/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/url.c?r…
============================================================================== --- trunk/rostests/winetests/winhttp/url.c [iso-8859-1] (original) +++ trunk/rostests/winetests/winhttp/url.c [iso-8859-1] Thu Sep 25 15:10:35 2014 @@ -71,6 +71,7 @@ {'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0}; static const WCHAR url14[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o',' ','g','/','p','a','t','h',' ','w','i','t','h',' ','s','p','a','c','e','s',0}; +static const WCHAR url15[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0}; static const WCHAR url_k1[] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d', @@ -462,10 +463,13 @@ reset_url_components( &uc ); ret = WinHttpCrackUrl( url_k9, 0, 0, &uc ); ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() ); - ok( uc.lpszUrlPath == url_k9 + 14, "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) ); + ok( uc.lpszUrlPath == url_k9 + 14 || broken(uc.lpszUrlPath == url_k9 + 13) /* win8 */, + "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) ); ok( uc.dwUrlPathLength == 0, "unexpected path length: %u\n", uc.dwUrlPathLength ); - ok( uc.lpszExtraInfo == url_k9 + 14, "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) ); - ok( uc.dwExtraInfoLength == 0, "unexpected extra info length: %u\n", uc.dwExtraInfoLength ); + ok( uc.lpszExtraInfo == url_k9 + 14 || broken(uc.lpszExtraInfo == url_k9 + 13) /* win8 */, + "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) ); + ok( uc.dwExtraInfoLength == 0 || broken(uc.dwExtraInfoLength == 1) /* win8 */, + "unexpected extra info length: %u\n", uc.dwExtraInfoLength ); reset_url_components( &uc ); ret = WinHttpCrackUrl( url_k10, 0, 0, &uc ); @@ -622,6 +626,73 @@ ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() ); ok( !lstrcmpW( uc.lpszHostName, hostnameW ), "unexpected host name\n" ); ok( !lstrcmpW( uc.lpszUrlPath, pathW ), "unexpected path\n" ); + + uc.dwStructSize = sizeof(uc); + uc.lpszScheme = NULL; + uc.dwSchemeLength = 0; + uc.nScheme = 0; + uc.lpszHostName = NULL; + uc.dwHostNameLength = ~0u; + uc.nPort = 0; + uc.lpszUserName = NULL; + uc.dwUserNameLength = ~0u; + uc.lpszPassword = NULL; + uc.dwPasswordLength = ~0u; + uc.lpszUrlPath = NULL; + uc.dwUrlPathLength = ~0u; + uc.lpszExtraInfo = NULL; + uc.dwExtraInfoLength = ~0u; + ret = WinHttpCrackUrl( url15, 0, 0, &uc ); + ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() ); + ok( !uc.lpszScheme, "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) ); + ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength ); + ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme %u\n", uc.nScheme ); + ok( !lstrcmpW( uc.lpszHostName, url15 + 7 ), "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) ); + ok( uc.dwHostNameLength == 14, "unexpected length %u\n", uc.dwHostNameLength ); + ok( uc.nPort == 80, "unexpected port %u\n", uc.nPort ); + ok( !uc.lpszUserName, "unexpected username\n" ); + ok( !uc.dwUserNameLength, "unexpected length %u\n", uc.dwUserNameLength ); + ok( !uc.lpszPassword, "unexpected password\n" ); + ok( !uc.dwPasswordLength, "unexpected length %u\n", uc.dwPasswordLength ); + ok( !lstrcmpW( uc.lpszUrlPath, url15 + 21 ), "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) ); + ok( uc.dwUrlPathLength == 5, "unexpected length %u\n", uc.dwUrlPathLength ); + ok( !uc.lpszExtraInfo[0], "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) ); + ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength ); + + uc.dwStructSize = sizeof(uc); + uc.lpszScheme = scheme; + uc.dwSchemeLength = 0; + uc.nScheme = 0; + uc.lpszHostName = NULL; + uc.dwHostNameLength = 0; + uc.nPort = 0; + uc.lpszUserName = NULL; + uc.dwUserNameLength = ~0u; + uc.lpszPassword = NULL; + uc.dwPasswordLength = ~0u; + uc.lpszUrlPath = NULL; + uc.dwUrlPathLength = 0; + uc.lpszExtraInfo = NULL; + uc.dwExtraInfoLength = 0; + SetLastError( 0xdeadbeef ); + ret = WinHttpCrackUrl( url15, 0, 0, &uc ); + error = GetLastError(); + ok( !ret, "WinHttpCrackUrl succeeded\n" ); + ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error ); + ok( !lstrcmpW( uc.lpszScheme, http ), "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) ); + ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength ); + ok( uc.nScheme == 0, "unexpected scheme %u\n", uc.nScheme ); + ok( !uc.lpszHostName, "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) ); + ok( uc.dwHostNameLength == 0, "unexpected length %u\n", uc.dwHostNameLength ); + ok( uc.nPort == 0, "unexpected port %u\n", uc.nPort ); + ok( !uc.lpszUserName, "unexpected username\n" ); + ok( uc.dwUserNameLength == ~0u, "unexpected length %u\n", uc.dwUserNameLength ); + ok( !uc.lpszPassword, "unexpected password\n" ); + ok( uc.dwPasswordLength == ~0u, "unexpected length %u\n", uc.dwPasswordLength ); + ok( !uc.lpszUrlPath, "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) ); + ok( uc.dwUrlPathLength == 0, "unexpected length %u\n", uc.dwUrlPathLength ); + ok( !uc.lpszExtraInfo, "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) ); + ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength ); } START_TEST(url) Modified: trunk/rostests/winetests/winhttp/winhttp.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/winhttp…
============================================================================== --- trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] (original) +++ trunk/rostests/winetests/winhttp/winhttp.c [iso-8859-1] Thu Sep 25 15:10:35 2014 @@ -24,7 +24,6 @@ #define COBJMACROS #include <stdarg.h> -//#include <stdlib.h> #include <windef.h> #include <winbase.h> #include <ole2.h> @@ -33,7 +32,6 @@ #include <winhttp.h> #include <wincrypt.h> #include <winreg.h> -//#include <winsock.h> //#include "initguid.h" #include <httprequest.h> @@ -273,8 +271,14 @@ ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSendRequest(req, empty, 0, NULL, 0, 0, 0); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError()); + done: WinHttpCloseHandle(req); WinHttpCloseHandle(con); WinHttpCloseHandle(ses); @@ -323,6 +327,11 @@ context++; ret = WinHttpSendRequest(request, content_type, header_len, post_data, optional_len, total_len, context); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret == TRUE, "WinHttpSendRequest failed: %u\n", GetLastError()); context = 0; @@ -354,9 +363,9 @@ ok(bytes_rw == sizeof(test_post) - 1, "Read %u bytes\n", bytes_rw); ok(!memcmp(buffer, test_post, sizeof(test_post) - 1), "Data read did not match.\n"); + done: ret = WinHttpCloseHandle(request); ok(ret == TRUE, "WinHttpCloseHandle failed on closing request, got %d.\n", ret); - done: ret = WinHttpCloseHandle(connection); ok(ret == TRUE, "WinHttpCloseHandle failed on closing connection, got %d.\n", ret); ret = WinHttpCloseHandle(session); @@ -853,18 +862,17 @@ WinHttpSetStatusCallback(req, cert_error, WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, 0); ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); - ok(ret, "failed to send request %u\n", GetLastError()); - if (!ret) + if (!ret && (GetLastError() == ERROR_WINHTTP_SECURE_FAILURE || GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT)) { skip("secure connection failed, skipping remaining secure tests\n"); goto cleanup; } + ok(ret, "failed to send request %u\n", GetLastError()); size = sizeof(cert); ret = WinHttpQueryOption(req, WINHTTP_OPTION_SERVER_CERT_CONTEXT, &cert, &size ); ok(ret, "failed to retrieve certificate context %u\n", GetLastError()); - if (ret) - CertFreeCertificateContext(cert); + if (ret) CertFreeCertificateContext(cert); size = sizeof(bitness); ret = WinHttpQueryOption(req, WINHTTP_OPTION_SECURITY_KEY_BITNESS, &bitness, &size ); @@ -928,6 +936,11 @@ ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError()); ret = WinHttpReceiveResponse(req, NULL); @@ -944,6 +957,11 @@ ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request %u\n", GetLastError()); ret = WinHttpReceiveResponse(req, NULL); @@ -967,6 +985,7 @@ ok(ret, "failed unexpectedly %u\n", GetLastError()); ok(status == 200, "request failed unexpectedly %u\n", status); +done: WinHttpCloseHandle(req); WinHttpCloseHandle(con); WinHttpCloseHandle(ses); @@ -1727,12 +1746,11 @@ SetLastError(0xdeadbeef); ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); - if(ret == 1) + if (ret) { skip("nxdomain returned success. Broken ISP redirects?\n"); - return; + goto done; } - ok(!ret, "sent request\n"); ok(GetLastError() == ERROR_WINHTTP_NAME_NOT_RESOLVED, "expected ERROR_WINHTTP_NAME_NOT_RESOLVED got %u\n", GetLastError()); @@ -1757,8 +1775,14 @@ ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok(ret, "failed to send request\n"); + done: WinHttpCloseHandle(req); WinHttpCloseHandle(con); WinHttpCloseHandle(ses); @@ -1775,18 +1799,16 @@ "Server: winetest\r\n" "\r\n"; +static const char nocontentmsg[] = +"HTTP/1.1 204 No Content\r\n" +"Server: winetest\r\n" +"\r\n"; + static const char noauthmsg[] = "HTTP/1.1 401 Unauthorized\r\n" "Server: winetest\r\n" "Connection: close\r\n" "WWW-Authenticate: Basic realm=\"placebo\"\r\n" -"\r\n"; - -static const char proxymsg[] = -"HTTP/1.1 407 Proxy Authentication Required\r\n" -"Server: winetest\r\n" -"Proxy-Connection: close\r\n" -"Proxy-Authenticate: Basic realm=\"placebo\"\r\n" "\r\n"; struct server_info @@ -1865,6 +1887,10 @@ { send(c, page1, sizeof page1 - 1, 0); } + if (strstr(buffer, "GET /no_content")) + { + send(c, nocontentmsg, sizeof nocontentmsg - 1, 0); + } if (strstr(buffer, "GET /quit")) { send(c, okmsg, sizeof okmsg - 1, 0); @@ -2098,6 +2124,83 @@ } WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + +static void test_no_content(int port) +{ + static const WCHAR no_contentW[] = {'/','n','o','_','c','o','n','t','e','n','t',0}; + HINTERNET ses, con, req; + WCHAR buf[128]; + DWORD size, len = sizeof(buf), bytes_read, status; + BOOL ret; + + ses = WinHttpOpen(test_useragent, 0, NULL, NULL, 0); + ok(ses != NULL, "failed to open session %u\n", GetLastError()); + + con = WinHttpConnect(ses, localhostW, port, 0); + ok(con != NULL, "failed to open a connection %u\n", GetLastError()); + + req = WinHttpOpenRequest(con, NULL, no_contentW, NULL, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + size = 12345; + SetLastError(0xdeadbeef); + ret = WinHttpQueryDataAvailable(req, &size); + todo_wine { + ok(!ret, "expected error\n"); + ok(GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, + "expected ERROR_WINHTTP_INCORRECT_HANDLE_STATE, got 0x%08x\n", GetLastError()); + ok(size == 12345 || broken(size == 0) /* Win <= 2003 */, + "expected 12345, got %u\n", size); + } + + ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); + ok(ret, "expected success\n"); + + ret = WinHttpReceiveResponse(req, NULL); + ok(ret, "expected success\n"); + + size = sizeof(status); + ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, + NULL, &status, &size, NULL); + ok(ret, "expected success\n"); + ok(status == 204, "expected status 204, got %d\n", status); + + SetLastError(0xdeadbeef); + size = sizeof(status); + status = 12345; + ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_CONTENT_LENGTH | WINHTTP_QUERY_FLAG_NUMBER, + NULL, &status, &size, 0); + ok(!ret, "expected no content-length header\n"); + ok(GetLastError() == ERROR_WINHTTP_HEADER_NOT_FOUND, + "wrong error %u\n", GetLastError() ); + ok(status == 12345, "expected 0, got %d\n", status); + + size = 12345; + ret = WinHttpQueryDataAvailable(req, &size); + ok(ret, "expected success\n"); + ok(size == 0, "expected 0, got %d\n", size); + + ret = WinHttpReadData(req, buf, len, &bytes_read); + ok( bytes_read == 0, "expected 0, got %u available\n", bytes_read ); + + size = 12345; + ret = WinHttpQueryDataAvailable(req, &size); + ok(ret, "expected success\n"); + ok(size == 0, "expected 0, got %d\n", size); + + WinHttpCloseHandle(req); + + size = 12345; + SetLastError(0xdeadbeef); + ret = WinHttpQueryDataAvailable(req, &size); + ok(!ret, "expected error\n"); + ok(GetLastError() == ERROR_INVALID_HANDLE, + "expected ERROR_INVALID_HANDLE, got 0x%08x\n", GetLastError()); + ok(size == 12345, "expected 12345, got %u\n", size); + WinHttpCloseHandle(con); WinHttpCloseHandle(ses); } @@ -2464,6 +2567,8 @@ method = SysAllocString( method1W ); SysFreeString( url ); url = SysAllocString( url1W ); + V_VT( &async ) = VT_ERROR; + V_ERROR( &async ) = DISP_E_PARAMNOTFOUND; hr = IWinHttpRequest_Open( req, method, url, async ); ok( hr == S_OK, "got %08x\n", hr ); @@ -3000,6 +3105,11 @@ if (!req) goto done; ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 ); + if (!ret && GetLastError() == ERROR_WINHTTP_CANNOT_CONNECT) + { + skip("connection failed, skipping\n"); + goto done; + } ok( ret, "WinHttpSendRequest failed with error %u\n", GetLastError() ); ret = WinHttpReceiveResponse( req, NULL ); @@ -3093,6 +3203,7 @@ test_connection_info(si.port); test_basic_request(si.port, NULL, basicW); test_no_headers(si.port); + test_no_content(si.port); test_basic_authentication(si.port); test_bad_header(si.port); test_multiple_reads(si.port);
10 years, 3 months
1
0
0
0
[akhaldi] 64273: [WINHTTP] * Sync with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:10:02 2014 New Revision: 64273 URL:
http://svn.reactos.org/svn/reactos?rev=64273&view=rev
Log: [WINHTTP] * Sync with Wine 1.7.27. CORE-8540 Removed: trunk/reactos/dll/win32/winhttp/pac.js Modified: trunk/reactos/dll/win32/winhttp/CMakeLists.txt trunk/reactos/dll/win32/winhttp/net.c trunk/reactos/dll/win32/winhttp/request.c trunk/reactos/dll/win32/winhttp/rsrc.rc trunk/reactos/dll/win32/winhttp/session.c trunk/reactos/dll/win32/winhttp/url.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/winhttp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/CMakeLis…
============================================================================== --- trunk/reactos/dll/win32/winhttp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/CMakeLists.txt [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -27,7 +27,7 @@ set_module_type(winhttp win32dll) target_link_libraries(winhttp uuid wine) add_delay_importlibs(winhttp oleaut32 ole32 crypt32 secur32) -add_importlibs(winhttp user32 advapi32 ws2_32 msvcrt kernel32 ntdll) +add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy msvcrt kernel32 ntdll) add_dependencies(winhttp stdole2) # wininet_tlb.tlb needs stdole2.tlb add_pch(winhttp winhttp_private.h SOURCE) add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/dll/win32/winhttp/net.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/net.c?re…
============================================================================== --- trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -126,6 +126,28 @@ #define ioctlsocket unix_ioctl #endif +static int sock_send(int fd, const void *msg, size_t len, int flags) +{ + int ret; + do + { + ret = send(fd, msg, len, flags); + } + while(ret == -1 && errno == EINTR); + return ret; +} + +static int sock_recv(int fd, void *msg, size_t len, int flags) +{ + int ret; + do + { + ret = recv(fd, msg, len, flags); + } + while(ret == -1 && errno == EINTR); + return ret; +} + static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags ) { HCERTSTORE store = cert->hCertStore; @@ -331,7 +353,7 @@ res = sock_get_error( errno ); if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) { - // ReactOS: use select instead of poll + /* ReactOS: use select instead of poll */ fd_set outfd; struct timeval tv; @@ -396,7 +418,7 @@ TRACE("sending %u bytes\n", out_buf.cbBuffer); - size = send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); + size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0); if(size != out_buf.cbBuffer) { ERR("send failed\n"); res = ERROR_WINHTTP_SECURE_CHANNEL_ERROR; @@ -435,7 +457,7 @@ read_buf_size += 1024; } - size = recv(conn->socket, (char *)(read_buf+in_bufs[0].cbBuffer), read_buf_size-in_bufs[0].cbBuffer, 0); + size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0); if(size < 1) { WARN("recv error\n"); status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR; @@ -481,6 +503,7 @@ } } + heap_free(read_buf); if(status != SEC_E_OK || res != ERROR_SUCCESS) { WARN("Failed to initialize security context failed: %08x\n", status); @@ -516,7 +539,7 @@ return FALSE; } - if(send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) { + if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) { WARN("send failed\n"); return FALSE; } @@ -546,7 +569,7 @@ return TRUE; } - if ((*sent = send( conn->socket, msg, len, 0 )) == -1) + if ((*sent = sock_send( conn->socket, msg, len, 0 )) == -1) { set_last_error( sock_get_error( errno ) ); return FALSE; @@ -572,7 +595,7 @@ heap_free(conn->extra_buf); conn->extra_buf = NULL; }else { - buf_len = recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0); + buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0); if(buf_len < 0) { WARN("recv failed\n"); return FALSE; @@ -604,7 +627,7 @@ case SEC_E_INCOMPLETE_MESSAGE: assert(buf_len < ssl_buf_size); - size = recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0); + size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0); if(size < 1) return FALSE; @@ -697,7 +720,7 @@ *recvd = size; return TRUE; } - if ((*recvd = recv( conn->socket, buf, len, flags )) == -1) + if ((*recvd = sock_recv( conn->socket, buf, len, flags )) == -1) { set_last_error( sock_get_error( errno ) ); return FALSE; Removed: trunk/reactos/dll/win32/winhttp/pac.js URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/pac.js?r…
============================================================================== --- trunk/reactos/dll/win32/winhttp/pac.js [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/pac.js (removed) @@ -1,244 +0,0 @@ -/* - * Copyright 2011 Hans Leidekker for CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - * Based on nsProxyAutoConfig.js from
mozilla.org
. - */ - -function myIpAddress() { - try { - return dns_resolve(''); - } catch (e) { - return '127.0.0.1'; - } -} - -function dnsResolve(host) { - try { - return dns_resolve(host); - } catch (e) { - return null; - } -} - -function dnsDomainIs(host, domain) { - return (host.length >= domain.length && - host.substring(host.length - domain.length) == domain); -} - -function dnsDomainLevels(host) { - return host.split('.').length-1; -} - -function convert_addr(ipchars) { - var bytes = ipchars.split('.'); - var result = ((bytes[0] & 0xff) << 24) | - ((bytes[1] & 0xff) << 16) | - ((bytes[2] & 0xff) << 8) | - (bytes[3] & 0xff); - return result; -} - -function isInNet(ipaddr, pattern, maskstr) { - var test = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ipaddr); - if (test == null) { - ipaddr = dnsResolve(ipaddr); - if (ipaddr == null) - return false; - } else if (test[1] > 255 || test[2] > 255 || - test[3] > 255 || test[4] > 255) { - return false; // not an IP address - } - var host = convert_addr(ipaddr); - var pat = convert_addr(pattern); - var mask = convert_addr(maskstr); - return ((host & mask) == (pat & mask)); -} - -function isPlainHostName(host) { - return (host.search('\\.') == -1); -} - -function isResolvable(host) { - var ip = dnsResolve(host); - return (ip != null); -} - -function localHostOrDomainIs(host, hostdom) { - return (host == hostdom) || - (hostdom.lastIndexOf(host + '.', 0) == 0); -} - -function shExpMatch(url, pattern) { - pattern = pattern.replace(/\./g, '\\.'); - pattern = pattern.replace(/\*/g, '.*'); - pattern = pattern.replace(/\?/g, '.'); - var newRe = new RegExp('^'+pattern+'$'); - return newRe.test(url); -} - -var wdays = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6}; -var months = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11}; - -function weekdayRange() { - function getDay(weekday) { - if (weekday in wdays) { - return wdays[weekday]; - } - return -1; - } - var date = new Date(); - var argc = arguments.length; - var wday; - if (argc < 1) - return false; - if (arguments[argc - 1] == 'GMT') { - argc--; - wday = date.getUTCDay(); - } else { - wday = date.getDay(); - } - var wd1 = getDay(arguments[0]); - var wd2 = (argc == 2) ? getDay(arguments[1]) : wd1; - return (wd1 == -1 || wd2 == -1) ? false - : (wd1 <= wday && wday <= wd2); -} - -function dateRange() { - function getMonth(name) { - if (name in months) { - return months[name]; - } - return -1; - } - var date = new Date(); - var argc = arguments.length; - if (argc < 1) { - return false; - } - var isGMT = (arguments[argc - 1] == 'GMT'); - - if (isGMT) { - argc--; - } - // function will work even without explicit handling of this case - if (argc == 1) { - var tmp = parseInt(arguments[0]); - if (isNaN(tmp)) { - return ((isGMT ? date.getUTCMonth() : date.getMonth()) == getMonth(arguments[0])); - } else if (tmp < 32) { - return ((isGMT ? date.getUTCDate() : date.getDate()) == tmp); - } else { - return ((isGMT ? date.getUTCFullYear() : date.getFullYear()) == tmp); - } - } - var year = date.getFullYear(); - var date1, date2; - date1 = new Date(year, 0, 1, 0, 0, 0); - date2 = new Date(year, 11, 31, 23, 59, 59); - var adjustMonth = false; - for (var i = 0; i < (argc >> 1); i++) { - var tmp = parseInt(arguments[i]); - if (isNaN(tmp)) { - var mon = getMonth(arguments[i]); - date1.setMonth(mon); - } else if (tmp < 32) { - adjustMonth = (argc <= 2); - date1.setDate(tmp); - } else { - date1.setFullYear(tmp); - } - } - for (var i = (argc >> 1); i < argc; i++) { - var tmp = parseInt(arguments[i]); - if (isNaN(tmp)) { - var mon = getMonth(arguments[i]); - date2.setMonth(mon); - } else if (tmp < 32) { - date2.setDate(tmp); - } else { - date2.setFullYear(tmp); - } - } - if (adjustMonth) { - date1.setMonth(date.getMonth()); - date2.setMonth(date.getMonth()); - } - if (isGMT) { - var tmp = date; - tmp.setFullYear(date.getUTCFullYear()); - tmp.setMonth(date.getUTCMonth()); - tmp.setDate(date.getUTCDate()); - tmp.setHours(date.getUTCHours()); - tmp.setMinutes(date.getUTCMinutes()); - tmp.setSeconds(date.getUTCSeconds()); - date = tmp; - } - return ((date1 <= date) && (date <= date2)); -} - -function timeRange() { - var argc = arguments.length; - var date = new Date(); - var isGMT= false; - - if (argc < 1) { - return false; - } - if (arguments[argc - 1] == 'GMT') { - isGMT = true; - argc--; - } - - var hour = isGMT ? date.getUTCHours() : date.getHours(); - var date1, date2; - date1 = new Date(); - date2 = new Date(); - - if (argc == 1) { - return (hour == arguments[0]); - } else if (argc == 2) { - return ((arguments[0] <= hour) && (hour <= arguments[1])); - } else { - switch (argc) { - case 6: - date1.setSeconds(arguments[2]); - date2.setSeconds(arguments[5]); - case 4: - var middle = argc >> 1; - date1.setHours(arguments[0]); - date1.setMinutes(arguments[1]); - date2.setHours(arguments[middle]); - date2.setMinutes(arguments[middle + 1]); - if (middle == 2) { - date2.setSeconds(59); - } - break; - default: - throw 'timeRange: bad number of arguments' - } - } - - if (isGMT) { - date.setFullYear(date.getUTCFullYear()); - date.setMonth(date.getUTCMonth()); - date.setDate(date.getUTCDate()); - date.setHours(date.getUTCHours()); - date.setMinutes(date.getUTCMinutes()); - date.setSeconds(date.getUTCSeconds()); - } - return ((date1 <= date) && (date <= date2)); -} Modified: trunk/reactos/dll/win32/winhttp/request.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/request.…
============================================================================== --- trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -2241,6 +2241,8 @@ request->read_chunked = FALSE; request->read_chunked_eof = FALSE; } + else heap_free( hostname ); + if (!(ret = add_host_header( request, WINHTTP_ADDREQ_FLAG_REPLACE ))) goto end; if (!(ret = open_connection( request ))) goto end; @@ -2269,7 +2271,6 @@ ret = TRUE; end: - if (!ret) heap_free( hostname ); heap_free( location ); return ret; } @@ -2981,7 +2982,7 @@ path[uc.dwUrlPathLength + uc.dwExtraInfoLength] = 0; if (!(verb = strdupW( method ))) goto error; - if (V_BOOL( &async )) flags |= WINHTTP_FLAG_ASYNC; + if (V_VT( &async ) == VT_BOOL && V_BOOL( &async )) flags |= WINHTTP_FLAG_ASYNC; if (!(hsession = WinHttpOpen( user_agentW, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, flags ))) { err = get_last_error(); @@ -3341,7 +3342,7 @@ { sa = V_ARRAY( &data ); if ((hr = SafeArrayAccessData( sa, (void **)&ptr )) != S_OK) return hr; - if ((hr = SafeArrayGetUBound( sa, 1, &size ) != S_OK)) + if ((hr = SafeArrayGetUBound( sa, 1, &size )) != S_OK) { SafeArrayUnaccessData( sa ); return hr; Modified: trunk/reactos/dll/win32/winhttp/rsrc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/rsrc.rc?…
============================================================================== --- trunk/reactos/dll/win32/winhttp/rsrc.rc [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/rsrc.rc [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -22,9 +22,6 @@ /* @makedep: winhttp_tlb.rgs */ 1 WINE_REGISTRY winhttp_tlb.rgs -/* @makedep: pac.js */ -pac.js 40 "pac.js" - #define WINE_FILEDESCRIPTION_STR "Wine HTTP Library" #define WINE_FILENAME_STR "winhttp.dll" #define WINE_FILEVERSION_MAJOR 5 Modified: trunk/reactos/dll/win32/winhttp/session.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/session.…
============================================================================== --- trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -27,9 +27,6 @@ #define DEFAULT_CONNECT_TIMEOUT 20000 #define DEFAULT_SEND_TIMEOUT 30000 #define DEFAULT_RECEIVE_TIMEOUT 30000 - -static const WCHAR global_funcsW[] = {'g','l','o','b','a','l','_','f','u','n','c','s',0}; -static const WCHAR dns_resolveW[] = {'d','n','s','_','r','e','s','o','l','v','e',0}; void set_last_error( DWORD error ) { @@ -1247,15 +1244,6 @@ return FALSE; } -static void printf_addr( const WCHAR *fmt, WCHAR *buf, struct sockaddr_in *addr ) -{ - sprintfW( buf, fmt, - (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 24 & 0xff), - (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 16 & 0xff), - (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 8 & 0xff), - (unsigned int)(ntohl( addr->sin_addr.s_addr ) & 0xff) ); -} - static int reverse_lookup( const struct addrinfo *ai, char *hostname, size_t len ) { int ret = -1; @@ -1287,12 +1275,42 @@ return ret; } +static BOOL get_system_proxy_autoconfig_url( char *buf, DWORD buflen ) +{ +#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + CFDictionaryRef settings = CFNetworkCopySystemProxySettings(); + const void *ref; + BOOL ret = FALSE; + + if (!settings) return FALSE; + + if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString ))) + { + CFRelease( settings ); + return FALSE; + } + if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII )) + { + TRACE( "returning %s\n", debugstr_a(buf) ); + ret = TRUE; + } + CFRelease( settings ); + return ret; +#else + FIXME( "no support on this platform\n" ); + return FALSE; +#endif +} + +#define INTERNET_MAX_URL_LENGTH 2084 + /*********************************************************************** * WinHttpDetectAutoProxyConfigUrl (winhttp.@) */ BOOL WINAPI WinHttpDetectAutoProxyConfigUrl( DWORD flags, LPWSTR *url ) { BOOL ret = FALSE; + char system_url[INTERNET_MAX_URL_LENGTH + 1]; TRACE("0x%08x, %p\n", flags, url); @@ -1300,6 +1318,14 @@ { set_last_error( ERROR_INVALID_PARAMETER ); return FALSE; + } + if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) )) + { + WCHAR *urlW; + + if (!(urlW = strdupAW( system_url ))) return FALSE; + *url = urlW; + return TRUE; } if (flags & WINHTTP_AUTO_DETECT_TYPE_DHCP) { @@ -1611,281 +1637,9 @@ return ret; } -static HRESULT WINAPI dispex_QueryInterface( - IDispatchEx *iface, REFIID riid, void **ppv ) -{ - *ppv = NULL; - - if (IsEqualGUID( riid, &IID_IUnknown ) || - IsEqualGUID( riid, &IID_IDispatch ) || - IsEqualGUID( riid, &IID_IDispatchEx )) - *ppv = iface; - else - return E_NOINTERFACE; - - return S_OK; -} - -static ULONG WINAPI dispex_AddRef( - IDispatchEx *iface ) -{ - return 2; -} - -static ULONG WINAPI dispex_Release( - IDispatchEx *iface ) -{ - return 1; -} - -static HRESULT WINAPI dispex_GetTypeInfoCount( - IDispatchEx *iface, UINT *info ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetTypeInfo( - IDispatchEx *iface, UINT info, LCID lcid, ITypeInfo **type_info ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetIDsOfNames( - IDispatchEx *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *id ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_Invoke( - IDispatchEx *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, - DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, UINT *err ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_DeleteMemberByName( - IDispatchEx *iface, BSTR name, DWORD flags ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_DeleteMemberByDispID( - IDispatchEx *iface, DISPID id ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetMemberProperties( - IDispatchEx *iface, DISPID id, DWORD flags_fetch, DWORD *flags ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetMemberName( - IDispatchEx *iface, DISPID id, BSTR *name ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetNextDispID( - IDispatchEx *iface, DWORD flags, DISPID id, DISPID *next ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI dispex_GetNameSpaceParent( - IDispatchEx *iface, IUnknown **unk ) -{ - return E_NOTIMPL; -} - -#define DISPID_GLOBAL_DNSRESOLVE 0x1000 - -static HRESULT WINAPI dispex_GetDispID( - IDispatchEx *iface, BSTR name, DWORD flags, DISPID *id ) -{ - if (!strcmpW( name, dns_resolveW )) - { - *id = DISPID_GLOBAL_DNSRESOLVE; - return S_OK; - } - return DISP_E_UNKNOWNNAME; -} - -static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result ) -{ -#ifdef HAVE_GETADDRINFO - static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0}; - WCHAR addr[16]; - struct addrinfo *ai, *elem; - char *hostnameA; - int res; - - if (hostname[0]) - hostnameA = strdupWA( hostname ); - else - hostnameA = get_computer_name( ComputerNamePhysicalDnsFullyQualified ); - - if (!hostnameA) return E_OUTOFMEMORY; - res = getaddrinfo( hostnameA, NULL, NULL, &ai ); - heap_free( hostnameA ); - if (res) return S_FALSE; - - elem = ai; - while (elem && elem->ai_family != AF_INET) elem = elem->ai_next; - if (!elem) - { - freeaddrinfo( ai ); - return S_FALSE; - } - printf_addr( fmtW, addr, (struct sockaddr_in *)elem->ai_addr ); - freeaddrinfo( ai ); - V_VT( result ) = VT_BSTR; - V_BSTR( result ) = SysAllocString( addr ); - return S_OK; -#else - FIXME("getaddrinfo not found at build time\n"); - return S_FALSE; -#endif -} - -static HRESULT WINAPI dispex_InvokeEx( - IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, - VARIANT *result, EXCEPINFO *exep, IServiceProvider *caller ) -{ - if (id == DISPID_GLOBAL_DNSRESOLVE) - { - if (params->cArgs != 1) return DISP_E_BADPARAMCOUNT; - if (V_VT(¶ms->rgvarg[0]) != VT_BSTR) return DISP_E_BADVARTYPE; - return dns_resolve( V_BSTR(¶ms->rgvarg[0]), result ); - } - return DISP_E_MEMBERNOTFOUND; -} - -static const IDispatchExVtbl dispex_vtbl = -{ - dispex_QueryInterface, - dispex_AddRef, - dispex_Release, - dispex_GetTypeInfoCount, - dispex_GetTypeInfo, - dispex_GetIDsOfNames, - dispex_Invoke, - dispex_GetDispID, - dispex_InvokeEx, - dispex_DeleteMemberByName, - dispex_DeleteMemberByDispID, - dispex_GetMemberProperties, - dispex_GetMemberName, - dispex_GetNextDispID, - dispex_GetNameSpaceParent -}; - -static IDispatchEx global_dispex = { &dispex_vtbl }; - -static HRESULT WINAPI site_QueryInterface( - IActiveScriptSite *iface, REFIID riid, void **ppv ) -{ - *ppv = NULL; - - if (IsEqualGUID( &IID_IUnknown, riid )) - *ppv = iface; - else if (IsEqualGUID( &IID_IActiveScriptSite, riid )) - *ppv = iface; - else - return E_NOINTERFACE; - - IUnknown_AddRef( (IUnknown *)*ppv ); - return S_OK; -} - -static ULONG WINAPI site_AddRef( - IActiveScriptSite *iface ) -{ - return 2; -} - -static ULONG WINAPI site_Release( - IActiveScriptSite *iface ) -{ - return 1; -} - -static HRESULT WINAPI site_GetLCID( - IActiveScriptSite *iface, LCID *lcid ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_GetItemInfo( - IActiveScriptSite *iface, LPCOLESTR name, DWORD mask, - IUnknown **item, ITypeInfo **type_info ) -{ - if (!strcmpW( name, global_funcsW ) && mask == SCRIPTINFO_IUNKNOWN) - { - *item = (IUnknown *)&global_dispex; - return S_OK; - } - return E_NOTIMPL; -} - -static HRESULT WINAPI site_GetDocVersionString( - IActiveScriptSite *iface, BSTR *version ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_OnScriptTerminate( - IActiveScriptSite *iface, const VARIANT *result, const EXCEPINFO *info ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_OnStateChange( - IActiveScriptSite *iface, SCRIPTSTATE state ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_OnScriptError( - IActiveScriptSite *iface, IActiveScriptError *error ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_OnEnterScript( - IActiveScriptSite *iface ) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI site_OnLeaveScript( - IActiveScriptSite *iface ) -{ - return E_NOTIMPL; -} - -static const IActiveScriptSiteVtbl site_vtbl = -{ - site_QueryInterface, - site_AddRef, - site_Release, - site_GetLCID, - site_GetItemInfo, - site_GetDocVersionString, - site_OnScriptTerminate, - site_OnStateChange, - site_OnScriptError, - site_OnEnterScript, - site_OnLeaveScript -}; - -static IActiveScriptSite script_site = { &site_vtbl }; - -static BOOL parse_script_result( VARIANT result, WINHTTP_PROXY_INFO *info ) -{ - static const WCHAR proxyW[] = {'P','R','O','X','Y'}; - const WCHAR *p; +static BOOL parse_script_result( const char *result, WINHTTP_PROXY_INFO *info ) +{ + const char *p; WCHAR *q; int len; @@ -1893,18 +1647,17 @@ info->lpszProxy = NULL; info->lpszProxyBypass = NULL; - if (V_VT( &result ) != VT_BSTR) return TRUE; - TRACE("%s\n", debugstr_w( V_BSTR( &result ) )); - - p = V_BSTR( &result ); + TRACE("%s\n", debugstr_a( result )); + + p = result; while (*p == ' ') p++; - len = strlenW( p ); - if (len >= 5 && !memicmpW( p, proxyW, sizeof(proxyW)/sizeof(WCHAR) )) + len = strlen( p ); + if (len >= 5 && !strncasecmp( p, "PROXY", sizeof("PROXY") - 1 )) { p += 5; while (*p == ' ') p++; if (!*p || *p == ';') return TRUE; - if (!(info->lpszProxy = q = strdupW( p ))) return FALSE; + if (!(info->lpszProxy = q = strdupAW( p ))) return FALSE; info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY; for (; *q; q++) { @@ -1918,128 +1671,7 @@ return TRUE; } -static BSTR include_pac_utils( BSTR script ) -{ - static const WCHAR pacjsW[] = {'p','a','c','.','j','s',0}; - HMODULE hmod = GetModuleHandleA( "winhttp.dll" ); - HRSRC rsrc; - DWORD size; - const char *data; - BSTR ret; - int len; - - if (!(rsrc = FindResourceW( hmod, pacjsW, (LPCWSTR)40 ))) return NULL; - size = SizeofResource( hmod, rsrc ); - data = LoadResource( hmod, rsrc ); - - len = MultiByteToWideChar( CP_ACP, 0, data, size, NULL, 0 ); - if (!(ret = SysAllocStringLen( NULL, len + SysStringLen( script ) + 1 ))) return NULL; - MultiByteToWideChar( CP_ACP, 0, data, size, ret, len ); - ret[len] = 0; - strcatW( ret, script ); - return ret; -} - -#ifdef _WIN64 -#define IActiveScriptParse_Release IActiveScriptParse64_Release -#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew -#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText -#else -#define IActiveScriptParse_Release IActiveScriptParse32_Release -#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew -#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText -#endif - -static BOOL run_script( const BSTR script, const WCHAR *url, WINHTTP_PROXY_INFO *info ) -{ - static const WCHAR jscriptW[] = {'J','S','c','r','i','p','t',0}; - static const WCHAR findproxyW[] = {'F','i','n','d','P','r','o','x','y','F','o','r','U','R','L',0}; - IActiveScriptParse *parser = NULL; - IActiveScript *engine = NULL; - IDispatch *dispatch = NULL; - BOOL ret = FALSE; - CLSID clsid; - DISPID dispid; - BSTR func = NULL, hostname = NULL, full_script = NULL; - URL_COMPONENTSW uc; - VARIANT args[2], result; - DISPPARAMS params; - HRESULT hr, init; - - memset( &uc, 0, sizeof(uc) ); - uc.dwStructSize = sizeof(uc); - if (!WinHttpCrackUrl( url, 0, 0, &uc )) return FALSE; - if (!(hostname = SysAllocStringLen( NULL, uc.dwHostNameLength + 1 ))) return FALSE; - memcpy( hostname, uc.lpszHostName, uc.dwHostNameLength * sizeof(WCHAR) ); - hostname[uc.dwHostNameLength] = 0; - - init = CoInitialize( NULL ); - hr = CLSIDFromProgID( jscriptW, &clsid ); - if (hr != S_OK) goto done; - - hr = CoCreateInstance( &clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, - &IID_IActiveScript, (void **)&engine ); - if (hr != S_OK) goto done; - - hr = IActiveScript_QueryInterface( engine, &IID_IActiveScriptParse, (void **)&parser ); - if (hr != S_OK) goto done; - - hr = IActiveScriptParse_InitNew( parser ); - if (hr != S_OK) goto done; - - hr = IActiveScript_SetScriptSite( engine, &script_site ); - if (hr != S_OK) goto done; - - hr = IActiveScript_AddNamedItem( engine, global_funcsW, SCRIPTITEM_GLOBALMEMBERS ); - if (hr != S_OK) goto done; - - if (!(full_script = include_pac_utils( script ))) goto done; - - hr = IActiveScriptParse_ParseScriptText( parser, full_script, NULL, NULL, NULL, 0, 0, 0, NULL, NULL ); - if (hr != S_OK) goto done; - - hr = IActiveScript_SetScriptState( engine, SCRIPTSTATE_STARTED ); - if (hr != S_OK) goto done; - - hr = IActiveScript_GetScriptDispatch( engine, NULL, &dispatch ); - if (hr != S_OK) goto done; - - if (!(func = SysAllocString( findproxyW ))) goto done; - hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &func, 1, LOCALE_SYSTEM_DEFAULT, &dispid ); - if (hr != S_OK) goto done; - - V_VT( &args[0] ) = VT_BSTR; - V_BSTR( &args[0] ) = hostname; - V_VT( &args[1] ) = VT_BSTR; - V_BSTR( &args[1] ) = SysAllocString( url ); - - params.rgvarg = args; - params.rgdispidNamedArgs = NULL; - params.cArgs = 2; - params.cNamedArgs = 0; - hr = IDispatch_Invoke( dispatch, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, - ¶ms, &result, NULL, NULL ); - VariantClear( &args[1] ); - if (hr != S_OK) - { - WARN("script failed 0x%08x\n", hr); - goto done; - } - ret = parse_script_result( result, info ); - -done: - SysFreeString( full_script ); - SysFreeString( hostname ); - SysFreeString( func ); - if (dispatch) IDispatch_Release( dispatch ); - if (parser) IActiveScriptParse_Release( parser ); - if (engine) IActiveScript_Release( engine ); - if (SUCCEEDED( init )) CoUninitialize(); - if (!ret) set_last_error( ERROR_WINHTTP_BAD_AUTO_PROXY_SCRIPT ); - return ret; -} - -static BSTR download_script( const WCHAR *url ) +static char *download_script( const WCHAR *url, DWORD *out_size ) { static const WCHAR typeW[] = {'*','/','*',0}; static const WCHAR *acceptW[] = {typeW, NULL}; @@ -2048,8 +1680,8 @@ URL_COMPONENTSW uc; DWORD status, size = sizeof(status), offset, to_read, bytes_read, flags = 0; char *tmp, *buffer = NULL; - BSTR script = NULL; - int len; + + *out_size = 0; memset( &uc, 0, sizeof(uc) ); uc.dwStructSize = sizeof(uc); @@ -2078,6 +1710,7 @@ if (!bytes_read) break; to_read -= bytes_read; offset += bytes_read; + *out_size += bytes_read; if (!to_read) { to_read = size; @@ -2086,19 +1719,51 @@ buffer = tmp; } } - len = MultiByteToWideChar( CP_ACP, 0, buffer, offset, NULL, 0 ); - if (!(script = SysAllocStringLen( NULL, len ))) goto done; - MultiByteToWideChar( CP_ACP, 0, buffer, offset, script, len ); - script[len] = 0; done: WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses ); - heap_free( buffer ); heap_free( hostname ); - if (!script) set_last_error( ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT ); - return script; + if (!buffer) set_last_error( ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT ); + return buffer; +} + +struct AUTO_PROXY_SCRIPT_BUFFER +{ + DWORD dwStructSize; + LPSTR lpszScriptBuffer; + DWORD dwScriptBufferSize; +}; + +BOOL WINAPI InternetDeInitializeAutoProxyDll(LPSTR, DWORD); +BOOL WINAPI InternetGetProxyInfo(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD); +BOOL WINAPI InternetInitializeAutoProxyDll(DWORD, LPSTR, LPSTR, void *, struct AUTO_PROXY_SCRIPT_BUFFER *); + +static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info ) +{ + BOOL ret; + char *result, *urlA; + DWORD len_result; + struct AUTO_PROXY_SCRIPT_BUFFER buffer; + + buffer.dwStructSize = sizeof(buffer); + buffer.lpszScriptBuffer = script; + buffer.dwScriptBufferSize = size; + + if (!(urlA = strdupWA( url ))) return FALSE; + if (!(ret = InternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buffer ))) + { + heap_free( urlA ); + return FALSE; + } + if ((ret = InternetGetProxyInfo( urlA, strlen(urlA), NULL, 0, &result, &len_result ))) + { + ret = parse_script_result( result, info ); + heap_free( result ); + } + heap_free( urlA ); + return InternetDeInitializeAutoProxyDll( NULL, 0 ); } /*********************************************************************** @@ -2110,7 +1775,8 @@ WCHAR *detected_pac_url = NULL; const WCHAR *pac_url; session_t *session; - BSTR script; + char *script; + DWORD size; BOOL ret = FALSE; TRACE("%p, %s, %p, %p\n", hsession, debugstr_w(url), options, info); @@ -2143,9 +1809,11 @@ if (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL) pac_url = options->lpszAutoConfigUrl; else pac_url = detected_pac_url; - if (!(script = download_script( pac_url ))) goto done; - ret = run_script( script, url, info ); - SysFreeString( script ); + if ((script = download_script( pac_url, &size ))) + { + ret = run_script( script, size, url, info ); + heap_free( script ); + } done: GlobalFree( detected_pac_url ); Modified: trunk/reactos/dll/win32/winhttp/url.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/url.c?re…
============================================================================== --- trunk/reactos/dll/win32/winhttp/url.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/url.c [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -23,6 +23,12 @@ static BOOL set_component( WCHAR **str, DWORD *str_len, WCHAR *value, DWORD len, DWORD flags ) { + if (*str && !*str_len) + { + set_last_error( ERROR_INVALID_PARAMETER ); + return FALSE; + } + if (!*str_len) return TRUE; if (!*str) { if (len && *str_len && (flags & (ICU_DECODE|ICU_ESCAPE))) @@ -160,6 +166,7 @@ { BOOL ret = FALSE; WCHAR *p, *q, *r, *url_decoded = NULL, *url_escaped = NULL; + INTERNET_SCHEME scheme = 0; TRACE("%s, %d, %x, %p\n", debugstr_w(url), len, flags, uc); @@ -193,8 +200,8 @@ set_last_error( ERROR_WINHTTP_UNRECOGNIZED_SCHEME ); return FALSE; } - if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) uc->nScheme = INTERNET_SCHEME_HTTP; - else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) uc->nScheme = INTERNET_SCHEME_HTTPS; + if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) scheme = INTERNET_SCHEME_HTTP; + else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) scheme = INTERNET_SCHEME_HTTPS; else { set_last_error( ERROR_WINHTTP_UNRECOGNIZED_SCHEME ); @@ -238,8 +245,8 @@ else { if (!(set_component( &uc->lpszHostName, &uc->dwHostNameLength, p, q - p, flags ))) goto exit; - if (uc->nScheme == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; - if (uc->nScheme == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; + if (scheme == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; + if (scheme == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; } if ((r = memchrW( q, '?', len - (q - url) ))) @@ -264,8 +271,8 @@ else { if (!(set_component( &uc->lpszHostName, &uc->dwHostNameLength, p, len - (p - url), flags ))) goto exit; - if (uc->nScheme == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; - if (uc->nScheme == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; + if (scheme == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT; + if (scheme == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT; } if (!(set_component( &uc->lpszUrlPath, &uc->dwUrlPathLength, (WCHAR *)url + len, 0, flags ))) goto exit; if (!(set_component( &uc->lpszExtraInfo, &uc->dwExtraInfoLength, (WCHAR *)url + len, 0, flags ))) goto exit; @@ -281,6 +288,7 @@ debugstr_wn( uc->lpszExtraInfo, uc->dwExtraInfoLength )); exit: + if (ret) uc->nScheme = scheme; heap_free( url_decoded ); heap_free( url_escaped ); return ret; Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Sep 25 15:10:02 2014 @@ -210,7 +210,7 @@ reactos/dll/win32/windowscodecsext # Synced to Wine-1.7.17 reactos/dll/win32/winemp3.acm # Synced to Wine-1.7.17 reactos/dll/win32/wing32 # Out of sync -reactos/dll/win32/winhttp # Synced to Wine-1.7.17 +reactos/dll/win32/winhttp # Synced to Wine-1.7.27 reactos/dll/win32/wininet # Synced to Wine-1.7.17 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
10 years, 3 months
1
0
0
0
[akhaldi] 64272: [WINHTTP] * Addendum to r64270.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:05:25 2014 New Revision: 64272 URL:
http://svn.reactos.org/svn/reactos?rev=64272&view=rev
Log: [WINHTTP] * Addendum to r64270. Modified: trunk/reactos/dll/win32/winhttp/winhttp_private.h Modified: trunk/reactos/dll/win32/winhttp/winhttp_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/winhttp_…
============================================================================== --- trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] Thu Sep 25 15:05:25 2014 @@ -299,37 +299,6 @@ extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN; -static inline const char *debugstr_variant( const VARIANT *v ) -{ - if (!v) return "(null)"; - switch (V_VT(v)) - { - case VT_EMPTY: - return "{VT_EMPTY}"; - case VT_NULL: - return "{VT_NULL}"; - case VT_I4: - return wine_dbg_sprintf( "{VT_I4: %d}", V_I4(v) ); - case VT_R8: - return wine_dbg_sprintf( "{VT_R8: %lf}", V_R8(v) ); - case VT_BSTR: - return wine_dbg_sprintf( "{VT_BSTR: %s}", debugstr_w(V_BSTR(v)) ); - case VT_DISPATCH: - return wine_dbg_sprintf( "{VT_DISPATCH: %p}", V_DISPATCH(v) ); - case VT_BOOL: - return wine_dbg_sprintf( "{VT_BOOL: %x}", V_BOOL(v) ); - case VT_UNKNOWN: - return wine_dbg_sprintf( "{VT_UNKNOWN: %p}", V_UNKNOWN(v) ); - case VT_UINT: - return wine_dbg_sprintf( "{VT_UINT: %u}", V_UINT(v) ); - case VT_BSTR|VT_BYREF: - return wine_dbg_sprintf( "{VT_BSTR|VT_BYREF: ptr %p, data %s}", - V_BSTRREF(v), V_BSTRREF(v) ? debugstr_w( *V_BSTRREF(v) ) : NULL ); - default: - return wine_dbg_sprintf( "{vt %d}", V_VT(v) ); - } -} - static inline void *heap_alloc( SIZE_T size ) { return HeapAlloc( GetProcessHeap(), 0, size );
10 years, 3 months
1
0
0
0
[akhaldi] 64271: [JSPROXY] * Import from Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Sep 25 15:02:29 2014 New Revision: 64271 URL:
http://svn.reactos.org/svn/reactos?rev=64271&view=rev
Log: [JSPROXY] * Import from Wine 1.7.27. CORE-8540 Added: trunk/reactos/dll/win32/jsproxy/ (with props) trunk/reactos/dll/win32/jsproxy/CMakeLists.txt (with props) trunk/reactos/dll/win32/jsproxy/jsproxy.spec (with props) trunk/reactos/dll/win32/jsproxy/main.c (with props) trunk/reactos/dll/win32/jsproxy/pac.js (with props) trunk/reactos/dll/win32/jsproxy/rsrc.rc (with props) Modified: trunk/reactos/dll/win32/CMakeLists.txt trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/CMakeLists.txt?r…
============================================================================== --- trunk/reactos/dll/win32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/CMakeLists.txt [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -69,6 +69,7 @@ add_subdirectory(itircl) add_subdirectory(itss) add_subdirectory(jscript) +add_subdirectory(jsproxy) add_subdirectory(kernel32) add_subdirectory(loadperf) add_subdirectory(localspl) Propchange: trunk/reactos/dll/win32/jsproxy/ ------------------------------------------------------------------------------ --- bugtraq:logregex (added) +++ bugtraq:logregex Thu Sep 25 15:02:29 2014 @@ -0,0 +1,2 @@ +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))? +(\d+) Propchange: trunk/reactos/dll/win32/jsproxy/ ------------------------------------------------------------------------------ bugtraq:message = See issue #%BUGID% for more details. Propchange: trunk/reactos/dll/win32/jsproxy/ ------------------------------------------------------------------------------ bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: trunk/reactos/dll/win32/jsproxy/ ------------------------------------------------------------------------------ tsvn:logminsize = 10 Added: trunk/reactos/dll/win32/jsproxy/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jsproxy/CMakeLis…
============================================================================== --- trunk/reactos/dll/win32/jsproxy/CMakeLists.txt (added) +++ trunk/reactos/dll/win32/jsproxy/CMakeLists.txt [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -0,0 +1,16 @@ + +add_definitions(-D__WINESRC__) +include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) + +spec2def(jsproxy.dll jsproxy.spec ADD_IMPORTLIB) + +list(APPEND SOURCE + main.c + ${CMAKE_CURRENT_BINARY_DIR}/jsproxy_stubs.c + ${CMAKE_CURRENT_BINARY_DIR}/jsproxy.def) + +add_library(jsproxy SHARED ${SOURCE} rsrc.rc) +set_module_type(jsproxy win32dll) +target_link_libraries(jsproxy uuid wine) +add_importlibs(jsproxy oleaut32 ole32 ws2_32 msvcrt kernel32 ntdll) +add_cd_file(TARGET jsproxy DESTINATION reactos/system32 FOR all) Propchange: trunk/reactos/dll/win32/jsproxy/CMakeLists.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/jsproxy/jsproxy.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jsproxy/jsproxy.…
============================================================================== --- trunk/reactos/dll/win32/jsproxy/jsproxy.spec (added) +++ trunk/reactos/dll/win32/jsproxy/jsproxy.spec [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -0,0 +1,5 @@ +@ stdcall InternetInitializeAutoProxyDll(long str str ptr ptr) JSPROXY_InternetInitializeAutoProxyDll +@ stub InternetInitializeExAutoProxyDll +@ stdcall InternetDeInitializeAutoProxyDll(str long) +@ stub InternetDeInitializeExAutoProxyDll +@ stdcall InternetGetProxyInfo(str long str long ptr ptr) Propchange: trunk/reactos/dll/win32/jsproxy/jsproxy.spec ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/jsproxy/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jsproxy/main.c?r…
============================================================================== --- trunk/reactos/dll/win32/jsproxy/main.c (added) +++ trunk/reactos/dll/win32/jsproxy/main.c [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -0,0 +1,642 @@ +/* + * Copyright 2014 Hans Leidekker for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <wine/config.h> + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define COBJMACROS + +#include <windef.h> +#include <winbase.h> +#include <objbase.h> +#include <oleauto.h> +#include <dispex.h> +#include <activscp.h> +#include <wininet.h> + +#include <wine/debug.h> +#include <wine/unicode.h> + +#ifdef HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif +#ifdef HAVE_NETDB_H +# include <netdb.h> +#endif +#if defined(__MINGW32__) || defined (_MSC_VER) +# include <ws2tcpip.h> +#else +# define closesocket close +# define ioctlsocket ioctl +#endif + +#ifndef __MINGW32__ +#define USE_WS_PREFIX +#endif + +static HINSTANCE instance; + +WINE_DEFAULT_DEBUG_CHANNEL(jsproxy); + +static CRITICAL_SECTION cs_jsproxy; +static CRITICAL_SECTION_DEBUG critsect_debug = +{ + 0, 0, &cs_jsproxy, + { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": cs_jsproxy") } +}; +static CRITICAL_SECTION cs_jsproxy = { &critsect_debug, -1, 0, 0, 0, 0 }; + +static const WCHAR global_funcsW[] = {'g','l','o','b','a','l','_','f','u','n','c','s',0}; +static const WCHAR dns_resolveW[] = {'d','n','s','_','r','e','s','o','l','v','e',0}; + +/****************************************************************** + * DllMain (jsproxy.@) + */ +BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + instance = hinst; + DisableThreadLibraryCalls( hinst ); + break; + + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +static inline void *heap_alloc( SIZE_T size ) +{ + return HeapAlloc( GetProcessHeap(), 0, size ); +} + +static inline BOOL heap_free( LPVOID mem ) +{ + return HeapFree( GetProcessHeap(), 0, mem ); +} + +static inline WCHAR *strdupAW( const char *src, DWORD len ) +{ + WCHAR *dst = NULL; + if (src) + { + int dst_len = MultiByteToWideChar( CP_ACP, 0, src, len, NULL, 0 ); + if ((dst = heap_alloc( (dst_len + 1) * sizeof(WCHAR) ))) + { + len = MultiByteToWideChar( CP_ACP, 0, src, len, dst, dst_len ); + dst[dst_len] = 0; + } + } + return dst; +} + +static inline char *strdupWA( const WCHAR *src ) +{ + char *dst = NULL; + if (src) + { + int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); + if ((dst = heap_alloc( len ))) WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL ); + } + return dst; +} + +static struct pac_script +{ + WCHAR *text; +} pac_script; +static struct pac_script *global_script = &pac_script; + +/****************************************************************** + * InternetDeInitializeAutoProxyDll (jsproxy.@) + */ +BOOL WINAPI InternetDeInitializeAutoProxyDll( LPSTR mime, DWORD reserved ) +{ + TRACE( "%s, %u\n", debugstr_a(mime), reserved ); + + EnterCriticalSection( &cs_jsproxy ); + + heap_free( global_script->text ); + global_script->text = NULL; + + LeaveCriticalSection( &cs_jsproxy ); + return TRUE; +} + +static WCHAR *load_script( const char *filename ) +{ + HANDLE handle; + DWORD size, bytes_read; + char *buffer; + int len; + WCHAR *script = NULL; + + handle = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 ); + if (handle == INVALID_HANDLE_VALUE) return NULL; + + size = GetFileSize( handle, NULL ); + if (!(buffer = heap_alloc( size ))) goto done; + if (!ReadFile( handle, buffer, size, &bytes_read, NULL ) || bytes_read != size) goto done; + + len = MultiByteToWideChar( CP_ACP, 0, buffer, size, NULL, 0 ); + if (!(script = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto done; + MultiByteToWideChar( CP_ACP, 0, buffer, size, script, len ); + script[len] = 0; + +done: + CloseHandle( handle ); + heap_free( buffer ); + return script; +} + +/****************************************************************** + * InternetInitializeAutoProxyDll (jsproxy.@) + */ +BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile, LPSTR mime, + AutoProxyHelperFunctions *callbacks, + LPAUTO_PROXY_SCRIPT_BUFFER buffer ) +{ + BOOL ret = FALSE; + + TRACE( "%u, %s, %s, %p, %p\n", version, debugstr_a(tmpfile), debugstr_a(mime), callbacks, buffer ); + + if (callbacks) FIXME( "callbacks not supported\n" ); + + EnterCriticalSection( &cs_jsproxy ); + + if (global_script->text) + { + LeaveCriticalSection( &cs_jsproxy ); + return FALSE; + } + if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer && + (global_script->text = strdupAW( buffer->lpszScriptBuffer, buffer->dwScriptBufferSize ))) ret = TRUE; + else if ((global_script->text = load_script( tmpfile ))) ret = TRUE; + + LeaveCriticalSection( &cs_jsproxy ); + return ret; +} + +static HRESULT WINAPI dispex_QueryInterface( + IDispatchEx *iface, REFIID riid, void **ppv ) +{ + *ppv = NULL; + + if (IsEqualGUID( riid, &IID_IUnknown ) || + IsEqualGUID( riid, &IID_IDispatch ) || + IsEqualGUID( riid, &IID_IDispatchEx )) + *ppv = iface; + else + return E_NOINTERFACE; + + return S_OK; +} + +static ULONG WINAPI dispex_AddRef( + IDispatchEx *iface ) +{ + return 2; +} + +static ULONG WINAPI dispex_Release( + IDispatchEx *iface ) +{ + return 1; +} + +static HRESULT WINAPI dispex_GetTypeInfoCount( + IDispatchEx *iface, UINT *info ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetTypeInfo( + IDispatchEx *iface, UINT info, LCID lcid, ITypeInfo **type_info ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetIDsOfNames( + IDispatchEx *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *id ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_Invoke( + IDispatchEx *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, + DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, UINT *err ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_DeleteMemberByName( + IDispatchEx *iface, BSTR name, DWORD flags ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_DeleteMemberByDispID( + IDispatchEx *iface, DISPID id ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetMemberProperties( + IDispatchEx *iface, DISPID id, DWORD flags_fetch, DWORD *flags ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetMemberName( + IDispatchEx *iface, DISPID id, BSTR *name ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetNextDispID( + IDispatchEx *iface, DWORD flags, DISPID id, DISPID *next ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI dispex_GetNameSpaceParent( + IDispatchEx *iface, IUnknown **unk ) +{ + return E_NOTIMPL; +} + +#define DISPID_GLOBAL_DNSRESOLVE 0x1000 + +static HRESULT WINAPI dispex_GetDispID( + IDispatchEx *iface, BSTR name, DWORD flags, DISPID *id ) +{ + if (!strcmpW( name, dns_resolveW )) + { + *id = DISPID_GLOBAL_DNSRESOLVE; + return S_OK; + } + return DISP_E_UNKNOWNNAME; +} + +static char *get_computer_name( COMPUTER_NAME_FORMAT format ) +{ + char *ret; + DWORD size = 0; + + GetComputerNameExA( format, NULL, &size ); + if (GetLastError() != ERROR_MORE_DATA) return NULL; + if (!(ret = heap_alloc( size ))) return NULL; + if (!GetComputerNameExA( format, ret, &size )) + { + heap_free( ret ); + return NULL; + } + return ret; +} + +static void printf_addr( const WCHAR *fmt, WCHAR *buf, struct sockaddr_in *addr ) +{ + sprintfW( buf, fmt, + (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 24 & 0xff), + (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 16 & 0xff), + (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 8 & 0xff), + (unsigned int)(ntohl( addr->sin_addr.s_addr ) & 0xff) ); +} + +static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result ) +{ +#ifdef HAVE_GETADDRINFO + static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0}; + WCHAR addr[16]; + struct addrinfo *ai, *elem; + char *hostnameA; + int res; + + if (hostname[0]) + hostnameA = strdupWA( hostname ); + else + hostnameA = get_computer_name( ComputerNamePhysicalDnsFullyQualified ); + + if (!hostnameA) return E_OUTOFMEMORY; + res = getaddrinfo( hostnameA, NULL, NULL, &ai ); + heap_free( hostnameA ); + if (res) return S_FALSE; + + elem = ai; + while (elem && elem->ai_family != AF_INET) elem = elem->ai_next; + if (!elem) + { + freeaddrinfo( ai ); + return S_FALSE; + } + printf_addr( fmtW, addr, (struct sockaddr_in *)elem->ai_addr ); + freeaddrinfo( ai ); + V_VT( result ) = VT_BSTR; + V_BSTR( result ) = SysAllocString( addr ); + return S_OK; +#else + FIXME("getaddrinfo not found at build time\n"); + return S_FALSE; +#endif +} + +static HRESULT WINAPI dispex_InvokeEx( + IDispatchEx *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *result, EXCEPINFO *exep, IServiceProvider *caller ) +{ + if (id == DISPID_GLOBAL_DNSRESOLVE) + { + if (params->cArgs != 1) return DISP_E_BADPARAMCOUNT; + if (V_VT(¶ms->rgvarg[0]) != VT_BSTR) return DISP_E_BADVARTYPE; + return dns_resolve( V_BSTR(¶ms->rgvarg[0]), result ); + } + return DISP_E_MEMBERNOTFOUND; +} + +static const IDispatchExVtbl dispex_vtbl = +{ + dispex_QueryInterface, + dispex_AddRef, + dispex_Release, + dispex_GetTypeInfoCount, + dispex_GetTypeInfo, + dispex_GetIDsOfNames, + dispex_Invoke, + dispex_GetDispID, + dispex_InvokeEx, + dispex_DeleteMemberByName, + dispex_DeleteMemberByDispID, + dispex_GetMemberProperties, + dispex_GetMemberName, + dispex_GetNextDispID, + dispex_GetNameSpaceParent +}; + +static IDispatchEx global_dispex = { &dispex_vtbl }; + +static HRESULT WINAPI site_QueryInterface( + IActiveScriptSite *iface, REFIID riid, void **ppv ) +{ + *ppv = NULL; + + if (IsEqualGUID( &IID_IUnknown, riid )) + *ppv = iface; + else if (IsEqualGUID( &IID_IActiveScriptSite, riid )) + *ppv = iface; + else + return E_NOINTERFACE; + + IUnknown_AddRef( (IUnknown *)*ppv ); + return S_OK; +} + +static ULONG WINAPI site_AddRef( + IActiveScriptSite *iface ) +{ + return 2; +} + +static ULONG WINAPI site_Release( + IActiveScriptSite *iface ) +{ + return 1; +} + +static HRESULT WINAPI site_GetLCID( + IActiveScriptSite *iface, LCID *lcid ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_GetItemInfo( + IActiveScriptSite *iface, LPCOLESTR name, DWORD mask, + IUnknown **item, ITypeInfo **type_info ) +{ + if (!strcmpW( name, global_funcsW ) && mask == SCRIPTINFO_IUNKNOWN) + { + *item = (IUnknown *)&global_dispex; + return S_OK; + } + return E_NOTIMPL; +} + +static HRESULT WINAPI site_GetDocVersionString( + IActiveScriptSite *iface, BSTR *version ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_OnScriptTerminate( + IActiveScriptSite *iface, const VARIANT *result, const EXCEPINFO *info ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_OnStateChange( + IActiveScriptSite *iface, SCRIPTSTATE state ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_OnScriptError( + IActiveScriptSite *iface, IActiveScriptError *error ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_OnEnterScript( + IActiveScriptSite *iface ) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI site_OnLeaveScript( + IActiveScriptSite *iface ) +{ + return E_NOTIMPL; +} + +static const IActiveScriptSiteVtbl site_vtbl = +{ + site_QueryInterface, + site_AddRef, + site_Release, + site_GetLCID, + site_GetItemInfo, + site_GetDocVersionString, + site_OnScriptTerminate, + site_OnStateChange, + site_OnScriptError, + site_OnEnterScript, + site_OnLeaveScript +}; + +static IActiveScriptSite script_site = { &site_vtbl }; + +static BSTR include_pac_utils( const WCHAR *script ) +{ + static const WCHAR pacjsW[] = {'p','a','c','.','j','s',0}; + HMODULE hmod = GetModuleHandleA( "jsproxy.dll" ); + HRSRC rsrc; + DWORD size; + const char *data; + BSTR ret; + int len; + + if (!(rsrc = FindResourceW( hmod, pacjsW, (LPCWSTR)40 ))) return NULL; + size = SizeofResource( hmod, rsrc ); + data = LoadResource( hmod, rsrc ); + + len = MultiByteToWideChar( CP_ACP, 0, data, size, NULL, 0 ); + if (!(ret = SysAllocStringLen( NULL, len + strlenW( script ) + 1 ))) return NULL; + MultiByteToWideChar( CP_ACP, 0, data, size, ret, len ); + strcpyW( ret + len, script ); + return ret; +} + +#ifdef _WIN64 +#define IActiveScriptParse_Release IActiveScriptParse64_Release +#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew +#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText +#else +#define IActiveScriptParse_Release IActiveScriptParse32_Release +#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew +#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText +#endif + +static BOOL run_script( const WCHAR *script, const WCHAR *url, const WCHAR *hostname, char **result_str, DWORD *result_len ) +{ + static const WCHAR jscriptW[] = {'J','S','c','r','i','p','t',0}; + static const WCHAR findproxyW[] = {'F','i','n','d','P','r','o','x','y','F','o','r','U','R','L',0}; + IActiveScriptParse *parser = NULL; + IActiveScript *engine = NULL; + IDispatch *dispatch = NULL; + BOOL ret = FALSE; + CLSID clsid; + DISPID dispid; + BSTR func = NULL, full_script = NULL; + VARIANT args[2], retval; + DISPPARAMS params; + HRESULT hr, init; + + init = CoInitialize( NULL ); + hr = CLSIDFromProgID( jscriptW, &clsid ); + if (hr != S_OK) goto done; + + hr = CoCreateInstance( &clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + &IID_IActiveScript, (void **)&engine ); + if (hr != S_OK) goto done; + + hr = IActiveScript_QueryInterface( engine, &IID_IActiveScriptParse, (void **)&parser ); + if (hr != S_OK) goto done; + + hr = IActiveScriptParse_InitNew( parser ); + if (hr != S_OK) goto done; + + hr = IActiveScript_SetScriptSite( engine, &script_site ); + if (hr != S_OK) goto done; + + hr = IActiveScript_AddNamedItem( engine, global_funcsW, SCRIPTITEM_GLOBALMEMBERS ); + if (hr != S_OK) goto done; + + if (!(full_script = include_pac_utils( script ))) goto done; + + hr = IActiveScriptParse_ParseScriptText( parser, full_script, NULL, NULL, NULL, 0, 0, 0, NULL, NULL ); + if (hr != S_OK) goto done; + + hr = IActiveScript_SetScriptState( engine, SCRIPTSTATE_STARTED ); + if (hr != S_OK) goto done; + + hr = IActiveScript_GetScriptDispatch( engine, NULL, &dispatch ); + if (hr != S_OK) goto done; + + if (!(func = SysAllocString( findproxyW ))) goto done; + hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &func, 1, LOCALE_SYSTEM_DEFAULT, &dispid ); + if (hr != S_OK) goto done; + + V_VT( &args[0] ) = VT_BSTR; + V_BSTR( &args[0] ) = SysAllocString( hostname ); + V_VT( &args[1] ) = VT_BSTR; + V_BSTR( &args[1] ) = SysAllocString( url ); + + params.rgvarg = args; + params.rgdispidNamedArgs = NULL; + params.cArgs = 2; + params.cNamedArgs = 0; + hr = IDispatch_Invoke( dispatch, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, + ¶ms, &retval, NULL, NULL ); + VariantClear( &args[0] ); + VariantClear( &args[1] ); + if (hr != S_OK) + { + WARN("script failed 0x%08x\n", hr); + goto done; + } + if ((*result_str = strdupWA( V_BSTR( &retval ) ))) + { + TRACE( "result: %s\n", debugstr_a(*result_str) ); + *result_len = strlen( *result_str ) + 1; + ret = TRUE; + } + VariantClear( &retval ); + +done: + SysFreeString( full_script ); + SysFreeString( func ); + if (dispatch) IDispatch_Release( dispatch ); + if (parser) IActiveScriptParse_Release( parser ); + if (engine) IActiveScript_Release( engine ); + if (SUCCEEDED( init )) CoUninitialize(); + return ret; +} + +/****************************************************************** + * InternetGetProxyInfo (jsproxy.@) + */ +BOOL WINAPI InternetGetProxyInfo( LPCSTR url, DWORD len_url, LPCSTR hostname, DWORD len_hostname, LPSTR *proxy, + LPDWORD len_proxy ) +{ + WCHAR *urlW = NULL, *hostnameW = NULL; + BOOL ret = FALSE; + + TRACE( "%s, %u, %s, %u, %p, %p\n", url, len_url, hostname, len_hostname, proxy, len_proxy ); + + EnterCriticalSection( &cs_jsproxy ); + + if (!global_script->text) goto done; + if (!(urlW = strdupAW( url, len_url ))) goto done; + if (hostname && !(hostnameW = strdupAW( hostname, len_hostname ))) goto done; + + TRACE( "%s\n", debugstr_w(global_script->text) ); + ret = run_script( global_script->text, urlW, hostnameW, proxy, len_proxy ); + +done: + heap_free( hostnameW ); + heap_free( urlW ); + LeaveCriticalSection( &cs_jsproxy ); + return ret; +} Propchange: trunk/reactos/dll/win32/jsproxy/main.c ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/jsproxy/pac.js URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jsproxy/pac.js?r…
============================================================================== --- trunk/reactos/dll/win32/jsproxy/pac.js (added) +++ trunk/reactos/dll/win32/jsproxy/pac.js [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -0,0 +1,244 @@ +/* + * Copyright 2011 Hans Leidekker for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * Based on nsProxyAutoConfig.js from
mozilla.org
. + */ + +function myIpAddress() { + try { + return dns_resolve(''); + } catch (e) { + return '127.0.0.1'; + } +} + +function dnsResolve(host) { + try { + return dns_resolve(host); + } catch (e) { + return null; + } +} + +function dnsDomainIs(host, domain) { + return (host.length >= domain.length && + host.substring(host.length - domain.length) == domain); +} + +function dnsDomainLevels(host) { + return host.split('.').length-1; +} + +function convert_addr(ipchars) { + var bytes = ipchars.split('.'); + var result = ((bytes[0] & 0xff) << 24) | + ((bytes[1] & 0xff) << 16) | + ((bytes[2] & 0xff) << 8) | + (bytes[3] & 0xff); + return result; +} + +function isInNet(ipaddr, pattern, maskstr) { + var test = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(ipaddr); + if (test == null) { + ipaddr = dnsResolve(ipaddr); + if (ipaddr == null) + return false; + } else if (test[1] > 255 || test[2] > 255 || + test[3] > 255 || test[4] > 255) { + return false; // not an IP address + } + var host = convert_addr(ipaddr); + var pat = convert_addr(pattern); + var mask = convert_addr(maskstr); + return ((host & mask) == (pat & mask)); +} + +function isPlainHostName(host) { + return (host.search('\\.') == -1); +} + +function isResolvable(host) { + var ip = dnsResolve(host); + return (ip != null); +} + +function localHostOrDomainIs(host, hostdom) { + return (host == hostdom) || + (hostdom.lastIndexOf(host + '.', 0) == 0); +} + +function shExpMatch(url, pattern) { + pattern = pattern.replace(/\./g, '\\.'); + pattern = pattern.replace(/\*/g, '.*'); + pattern = pattern.replace(/\?/g, '.'); + var newRe = new RegExp('^'+pattern+'$'); + return newRe.test(url); +} + +var wdays = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6}; +var months = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11}; + +function weekdayRange() { + function getDay(weekday) { + if (weekday in wdays) { + return wdays[weekday]; + } + return -1; + } + var date = new Date(); + var argc = arguments.length; + var wday; + if (argc < 1) + return false; + if (arguments[argc - 1] == 'GMT') { + argc--; + wday = date.getUTCDay(); + } else { + wday = date.getDay(); + } + var wd1 = getDay(arguments[0]); + var wd2 = (argc == 2) ? getDay(arguments[1]) : wd1; + return (wd1 == -1 || wd2 == -1) ? false + : (wd1 <= wday && wday <= wd2); +} + +function dateRange() { + function getMonth(name) { + if (name in months) { + return months[name]; + } + return -1; + } + var date = new Date(); + var argc = arguments.length; + if (argc < 1) { + return false; + } + var isGMT = (arguments[argc - 1] == 'GMT'); + + if (isGMT) { + argc--; + } + // function will work even without explicit handling of this case + if (argc == 1) { + var tmp = parseInt(arguments[0]); + if (isNaN(tmp)) { + return ((isGMT ? date.getUTCMonth() : date.getMonth()) == getMonth(arguments[0])); + } else if (tmp < 32) { + return ((isGMT ? date.getUTCDate() : date.getDate()) == tmp); + } else { + return ((isGMT ? date.getUTCFullYear() : date.getFullYear()) == tmp); + } + } + var year = date.getFullYear(); + var date1, date2; + date1 = new Date(year, 0, 1, 0, 0, 0); + date2 = new Date(year, 11, 31, 23, 59, 59); + var adjustMonth = false; + for (var i = 0; i < (argc >> 1); i++) { + var tmp = parseInt(arguments[i]); + if (isNaN(tmp)) { + var mon = getMonth(arguments[i]); + date1.setMonth(mon); + } else if (tmp < 32) { + adjustMonth = (argc <= 2); + date1.setDate(tmp); + } else { + date1.setFullYear(tmp); + } + } + for (var i = (argc >> 1); i < argc; i++) { + var tmp = parseInt(arguments[i]); + if (isNaN(tmp)) { + var mon = getMonth(arguments[i]); + date2.setMonth(mon); + } else if (tmp < 32) { + date2.setDate(tmp); + } else { + date2.setFullYear(tmp); + } + } + if (adjustMonth) { + date1.setMonth(date.getMonth()); + date2.setMonth(date.getMonth()); + } + if (isGMT) { + var tmp = date; + tmp.setFullYear(date.getUTCFullYear()); + tmp.setMonth(date.getUTCMonth()); + tmp.setDate(date.getUTCDate()); + tmp.setHours(date.getUTCHours()); + tmp.setMinutes(date.getUTCMinutes()); + tmp.setSeconds(date.getUTCSeconds()); + date = tmp; + } + return ((date1 <= date) && (date <= date2)); +} + +function timeRange() { + var argc = arguments.length; + var date = new Date(); + var isGMT= false; + + if (argc < 1) { + return false; + } + if (arguments[argc - 1] == 'GMT') { + isGMT = true; + argc--; + } + + var hour = isGMT ? date.getUTCHours() : date.getHours(); + var date1, date2; + date1 = new Date(); + date2 = new Date(); + + if (argc == 1) { + return (hour == arguments[0]); + } else if (argc == 2) { + return ((arguments[0] <= hour) && (hour <= arguments[1])); + } else { + switch (argc) { + case 6: + date1.setSeconds(arguments[2]); + date2.setSeconds(arguments[5]); + case 4: + var middle = argc >> 1; + date1.setHours(arguments[0]); + date1.setMinutes(arguments[1]); + date2.setHours(arguments[middle]); + date2.setMinutes(arguments[middle + 1]); + if (middle == 2) { + date2.setSeconds(59); + } + break; + default: + throw 'timeRange: bad number of arguments' + } + } + + if (isGMT) { + date.setFullYear(date.getUTCFullYear()); + date.setMonth(date.getUTCMonth()); + date.setDate(date.getUTCDate()); + date.setHours(date.getUTCHours()); + date.setMinutes(date.getUTCMinutes()); + date.setSeconds(date.getUTCSeconds()); + } + return ((date1 <= date) && (date <= date2)); +} Propchange: trunk/reactos/dll/win32/jsproxy/pac.js ------------------------------------------------------------------------------ svn:eol-style = native Added: trunk/reactos/dll/win32/jsproxy/rsrc.rc URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/jsproxy/rsrc.rc?…
============================================================================== --- trunk/reactos/dll/win32/jsproxy/rsrc.rc (added) +++ trunk/reactos/dll/win32/jsproxy/rsrc.rc [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Hans Leidekker for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* @makedep: pac.js */ +pac.js 40 "pac.js" Propchange: trunk/reactos/dll/win32/jsproxy/rsrc.rc ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Sep 25 15:02:29 2014 @@ -94,6 +94,7 @@ reactos/dll/win32/itircl # Synced to Wine-1.7.17 reactos/dll/win32/itss # Synced to Wine-1.7.17 reactos/dll/win32/jscript # Synced to Wine-1.7.17 +reactos/dll/win32/jsproxy # Synced to Wine-1.7.27 reactos/dll/win32/loadperf # Synced to Wine-1.7.17 reactos/dll/win32/localspl # Synced to Wine-1.7.17 reactos/dll/win32/localui # Synced to Wine-1.7.17
10 years, 3 months
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
42
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Results per page:
10
25
50
100
200