Re: mshtml: Use wininet to get and parse the proxy (try 2)
please ignore also that one. APPINFO_QueryOption needs to be fixed first Am 20.08.2011 17:19, schrieb André Hentschel:
fixed the leak --- dlls/mshtml/nsembed.c | 62 +++++++++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 32 deletions(-)
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c index 2bebf8b..c2581e6 100644 --- a/dlls/mshtml/nsembed.c +++ b/dlls/mshtml/nsembed.c @@ -27,6 +27,7 @@ #include "winbase.h" #include "winuser.h" #include "winreg.h" +#include "wininet.h" #include "ole2.h" #include "shlobj.h"
@@ -488,51 +489,48 @@ static void set_lang(nsIPrefBranch *pref)
static void set_proxy(nsIPrefBranch *pref) { - char proxy[512]; - char * proxy_port; - int proxy_port_num; - DWORD enabled = 0, res, size, type; - HKEY hkey; + CHAR hostname[INTERNET_MAX_HOST_NAME_LENGTH]; + URL_COMPONENTSA UrlComponents; + INTERNET_PROXY_INFOA *pi; + DWORD size;
- static const WCHAR proxy_keyW[] = - {'S','o','f','t','w','a','r','e', - '\\','M','i','c','r','o','s','o','f','t', - '\\','W','i','n','d','o','w','s', - '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n', - '\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0}; + InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, NULL, &size); + if (!size) return;
- res = RegOpenKeyW(HKEY_CURRENT_USER, proxy_keyW, &hkey); - if(res != ERROR_SUCCESS) - return; + pi = heap_alloc(size); + if (!pi) return;
- size = sizeof(enabled); - res = RegQueryValueExA(hkey, "ProxyEnable", 0, &type, (LPBYTE)&enabled, &size); - if(res != ERROR_SUCCESS || type != REG_DWORD || enabled == 0) + if(!InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, pi, &size)) { - RegCloseKey(hkey); + heap_free(pi); return; }
- size = sizeof(proxy); - res = RegQueryValueExA(hkey, "ProxyServer", 0, &type, (LPBYTE)proxy, &size); - RegCloseKey(hkey); - if(res != ERROR_SUCCESS || type != REG_SZ) - return; + if (pi->dwAccessType != INTERNET_OPEN_TYPE_PROXY) return;
- proxy_port = strchr(proxy, ':'); - if (!proxy_port) + memset( &UrlComponents, 0, sizeof(UrlComponents)); + UrlComponents.dwStructSize = sizeof(UrlComponents); + UrlComponents.lpszHostName = hostname; + UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH; + if(!InternetCrackUrlA(pi->lpszProxy, 0, 0, &UrlComponents)) + { + heap_free(pi); return; + } + + if(UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) + UrlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
- *proxy_port = 0; - proxy_port_num = atoi(proxy_port + 1); - TRACE("Setting proxy to %s, port %d\n", debugstr_a(proxy), proxy_port_num); + TRACE("Setting proxy to %s, port %d\n", UrlComponents.lpszHostName, UrlComponents.nPort);
- set_string_pref(pref, "network.proxy.http", proxy); - set_string_pref(pref, "network.proxy.ssl", proxy); + set_string_pref(pref, "network.proxy.http", UrlComponents.lpszHostName); + set_string_pref(pref, "network.proxy.ssl", UrlComponents.lpszHostName);
set_int_pref(pref, "network.proxy.type", 1); - set_int_pref(pref, "network.proxy.http_port", proxy_port_num); - set_int_pref(pref, "network.proxy.ssl_port", proxy_port_num); + set_int_pref(pref, "network.proxy.http_port", UrlComponents.nPort); + set_int_pref(pref, "network.proxy.ssl_port", UrlComponents.nPort); + + heap_free(pi); }
static void set_preferences(void)
-- Best Regards, André Hentschel
participants (2)
-
André Hentschel -
Dmitry Timoshkov