From: Daniel Lehman dlehman25@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=53531 --- dlls/msxml3/attribute.c | 45 +++++++++++++++++++++++++------------- dlls/msxml3/tests/domdoc.c | 4 ---- dlls/msxml4/tests/domdoc.c | 4 ---- dlls/msxml6/tests/domdoc.c | 12 ++-------- 4 files changed, 32 insertions(+), 33 deletions(-)
diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 6b8c7fba6d9..ebab7fdb03a 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -543,10 +543,12 @@ static HRESULT WINAPI domattr_get_namespaceURI( IXMLDOMAttribute *iface, BSTR* p) { - static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.', - 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 }; + static const WCHAR *w3xmlns = L"http://www.w3.org/2000/xmlns/"; domattr *This = impl_from_IXMLDOMAttribute( iface ); xmlNsPtr ns = This->node.node->ns; + BSTR nodename, pfx; + BOOL is6, isdefault; + HRESULT hr;
TRACE("(%p)->(%p)\n", This, p);
@@ -554,22 +556,35 @@ static HRESULT WINAPI domattr_get_namespaceURI( return E_INVALIDARG;
*p = NULL; + nodename = NULL; + hr = IXMLDOMAttribute_get_nodeName(iface, &nodename); + if (FAILED(hr)) + return hr; + + pfx = NULL; + hr = IXMLDOMAttribute_get_prefix(iface, &pfx); + if (FAILED(hr)) + { + SysFreeString(nodename); + return hr; + }
- if (ns) + is6 = xmldoc_version(This->node.node->doc) == MSXML6; + isdefault = !wcscmp(nodename, L"xmlns"); + if (isdefault || (pfx && !wcscmp(L"xmlns", pfx))) { - /* special case for default namespace definition */ - if (xmlStrEqual(This->node.node->name, xmlns)) - *p = bstr_from_xmlChar(xmlns); - else if (xmlStrEqual(ns->prefix, xmlns)) - { - if (xmldoc_version(This->node.node->doc) == MSXML6) - *p = SysAllocString(w3xmlns); - else - *p = SysAllocStringLen(NULL, 0); - } - else if (ns->href) - *p = bstr_from_xmlChar(ns->href); + if (is6) + *p = SysAllocString(w3xmlns); + else if (!ns || !isdefault) + *p = SysAllocStringLen(NULL, 0); + else + *p = SysAllocString(L"xmlns"); } + else if (ns && ns->href) + *p = bstr_from_xmlChar(ns->href); + + SysFreeString(nodename); + SysFreeString(pfx);
TRACE("uri: %s\n", debugstr_w(*p));
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index aef056a61b1..47719611bdc 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -13671,7 +13671,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -13712,7 +13711,6 @@ static void test_namespaces_as_attributes(void) { "" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -13796,13 +13794,11 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml4/tests/domdoc.c b/dlls/msxml4/tests/domdoc.c index 2880f9b7f37..00b9644d0a7 100644 --- a/dlls/msxml4/tests/domdoc.c +++ b/dlls/msxml4/tests/domdoc.c @@ -171,7 +171,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -212,7 +211,6 @@ static void test_namespaces_as_attributes(void) { "" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -292,13 +290,11 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else diff --git a/dlls/msxml6/tests/domdoc.c b/dlls/msxml6/tests/domdoc.c index a201ee5deae..467d077d756 100644 --- a/dlls/msxml6/tests/domdoc.c +++ b/dlls/msxml6/tests/domdoc.c @@ -67,12 +67,11 @@ struct attrtest_t { const char *uri; const char *prefix; const char *href; - BOOL todo; };
static struct attrtest_t attrtests[] = { - { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, - { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/", TRUE }, + { "xmlns", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, + { "xmlns", "nondefaulturi", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "http://www.w3.org/2000/xmlns/", NULL, "http://www.w3.org/2000/xmlns/" }, { "c", "nsref1", NULL, "nsref1" }, { "ns:c", "nsref1", "ns", "nsref1" }, @@ -120,7 +119,6 @@ static void test_create_attribute(void) str = NULL; hr = IXMLDOMNode_get_namespaceURI(node, &str); ok(hr == S_OK, "%d: unexpected hr %#lx\n", i, hr); - todo_wine_if(ptr->todo) ok(!lstrcmpW(str, _bstr_(ptr->href)) || broken(!ptr->prefix && !lstrcmpW(str, L"xmlns")), /* win7 msxml6 */ "%d: got uri %s, expected %s\n", i, wine_dbgstr_w(str), ptr->href); @@ -176,7 +174,6 @@ static void test_namespaces_as_attributes(void) const char *uris[3]; const char *texts[3]; const char *xmls[3]; - BOOL todo; }; static const struct test tests[] = { { @@ -217,7 +214,6 @@ static void test_namespaces_as_attributes(void) { "http://www.w3.org/2000/xmlns/" }, /* namespaceURI */ { "nshref" }, /* text */ { "xmlns="nshref"" }, /* xml */ - TRUE, /* todo */ }, /* no properties or namespaces */ { @@ -276,10 +272,8 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_prefix(item, &str); if (test->prefixes[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get prefix, hr %#lx.\n", hr); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else @@ -295,14 +289,12 @@ static void test_namespaces_as_attributes(void) hr = IXMLDOMNode_get_namespaceURI(item, &str); if (test->uris[i]) { - todo_wine_if(test->todo) { ok(hr == S_OK, "Failed to get namespace URI, hr %#lx.\n", hr); if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"), "got %s\n", wine_dbgstr_w(str)); else ok(!lstrcmpW(str, _bstr_(test->uris[i])), "got %s\n", wine_dbgstr_w(str)); - } SysFreeString(str); } else