diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c
index a6c66d18a20..e0b8f73438e 100644
--- a/dlls/mshtml/omnavigator.c
+++ b/dlls/mshtml/omnavigator.c
@@ -1008,6 +1008,7 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
char user_agent[512];
DWORD size;
HRESULT hres;
+ const unsigned skip_prefix = 8; /* strlen("Mozilla/") */
TRACE("(%p)->(%p)\n", This, p);
@@ -1016,17 +1017,17 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
if(FAILED(hres))
return hres;
- if(strncmp(user_agent, "Mozilla/", 8)) {
- FIXME("Unsupported user agent\n");
- return E_FAIL;
+ if(size <= skip_prefix) {
+ *p = NULL;
+ return S_OK;
}
- size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
+ size = MultiByteToWideChar(CP_ACP, 0, user_agent + skip_prefix, -1, NULL, 0);
*p = SysAllocStringLen(NULL, size-1);
if(!*p)
return E_OUTOFMEMORY;
- MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
+ MultiByteToWideChar(CP_ACP, 0, user_agent + skip_prefix, -1, *p, size);
return S_OK;
}
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 69b62069f3e..8f822995858 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -6228,6 +6228,7 @@ static void test_navigator(IHTMLDocument2 *doc)
HRESULT hres;
static const WCHAR v40[] = {'4','.','0'};
+ static char ua[] = "1234567890xxxABC";
hres = IHTMLDocument2_get_parentWindow(doc, &window);
ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
@@ -6336,6 +6337,17 @@ static void test_navigator(IHTMLDocument2 *doc)
skip("nonstandard user agent\n");
}
+ hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, sizeof(ua), 0);
+ ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
+
+ hres = IOmNavigator_get_appVersion(navigator, &bstr);
+ ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
+ ok(!strcmp_wa(bstr, ua+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
+ SysFreeString(bstr);
+
+ hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, buf, strlen(buf), 0);
+ ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
+
bstr = NULL;
hres = IOmNavigator_get_appMinorVersion(navigator, &bstr);
ok(hres == S_OK, "get_appMonorVersion failed: %08x\n", hres);