Commit 0b31c53e authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

msxml3: Handle null prefix in get_item.

parent d81df26f
...@@ -1827,11 +1827,16 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * ...@@ -1827,11 +1827,16 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode *
if (attrIndex < index) if (attrIndex < index)
return S_FALSE; return S_FALSE;
xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); if (!ns->prefix) {
if (!xmlns) xmlns = NULL;
return E_OUTOFMEMORY; curr = xmlNewProp(NULL, BAD_CAST "xmlns", ns->href);
} else {
xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns");
if (!xmlns)
return E_OUTOFMEMORY;
curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href);
}
if (!curr) { if (!curr) {
xmlFreeNs(xmlns); xmlFreeNs(xmlns);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -13773,9 +13773,7 @@ static void test_namespaces_as_attributes(void) ...@@ -13773,9 +13773,7 @@ static void test_namespaces_as_attributes(void)
{ {
item = NULL; item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
todo_wine_if(test->todo)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (hr != S_OK) continue;
str = NULL; str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str); hr = IXMLDOMNode_get_nodeName(item, &str);
...@@ -13787,8 +13785,10 @@ static void test_namespaces_as_attributes(void) ...@@ -13787,8 +13785,10 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_prefix(item, &str); hr = IXMLDOMNode_get_prefix(item, &str);
if (test->prefixes[i]) if (test->prefixes[i])
{ {
todo_wine_if(test->todo) {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->prefixes[i])), "got %s\n", wine_dbgstr_w(str));
}
SysFreeString(str); SysFreeString(str);
} }
else else
...@@ -13797,6 +13797,7 @@ static void test_namespaces_as_attributes(void) ...@@ -13797,6 +13797,7 @@ static void test_namespaces_as_attributes(void)
str = NULL; str = NULL;
hr = IXMLDOMNode_get_baseName(item, &str); hr = IXMLDOMNode_get_baseName(item, &str);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine_if(test->todo)
ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, _bstr_(test->basenames[i])), "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
...@@ -13804,6 +13805,7 @@ static void test_namespaces_as_attributes(void) ...@@ -13804,6 +13805,7 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_namespaceURI(item, &str); hr = IXMLDOMNode_get_namespaceURI(item, &str);
if (test->uris[i]) if (test->uris[i])
{ {
todo_wine_if(test->todo)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns")) if (test->prefixes[i] && !strcmp(test->prefixes[i], "xmlns"))
ok(!SysStringLen(str), "got %s\n", wine_dbgstr_w(str)); ok(!SysStringLen(str), "got %s\n", wine_dbgstr_w(str));
......
...@@ -256,9 +256,7 @@ static void test_namespaces_as_attributes(void) ...@@ -256,9 +256,7 @@ static void test_namespaces_as_attributes(void)
{ {
item = NULL; item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
todo_wine_if(test->todo)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (hr != S_OK) continue;
str = NULL; str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str); hr = IXMLDOMNode_get_nodeName(item, &str);
...@@ -271,9 +269,11 @@ static void test_namespaces_as_attributes(void) ...@@ -271,9 +269,11 @@ static void test_namespaces_as_attributes(void)
if (test->prefixes[i]) if (test->prefixes[i])
{ {
/* MSXML4 can report different results with different service packs */ /* MSXML4 can report different results with different service packs */
todo_wine_if(test->todo) {
ok(hr == S_OK || broken(hr == S_FALSE), "Unexpected hr %#lx.\n", hr); ok(hr == S_OK || broken(hr == S_FALSE), "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->prefixes[i]) || broken(!str), ok(!lstrcmpW(str, test->prefixes[i]) || broken(!str),
"got %s\n", wine_dbgstr_w(str)); "got %s\n", wine_dbgstr_w(str));
}
SysFreeString(str); SysFreeString(str);
} }
else else
...@@ -283,6 +283,7 @@ static void test_namespaces_as_attributes(void) ...@@ -283,6 +283,7 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_baseName(item, &str); hr = IXMLDOMNode_get_baseName(item, &str);
/* MSXML4 can report different results with different service packs */ /* MSXML4 can report different results with different service packs */
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine_if(test->todo)
ok(!lstrcmpW(str, test->basenames[i]) || broken(!lstrcmpW(str, L"xmlns")), ok(!lstrcmpW(str, test->basenames[i]) || broken(!lstrcmpW(str, L"xmlns")),
"got %s\n", wine_dbgstr_w(str)); "got %s\n", wine_dbgstr_w(str));
SysFreeString(str); SysFreeString(str);
...@@ -291,11 +292,13 @@ static void test_namespaces_as_attributes(void) ...@@ -291,11 +292,13 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_namespaceURI(item, &str); hr = IXMLDOMNode_get_namespaceURI(item, &str);
if (test->uris[i]) if (test->uris[i])
{ {
todo_wine_if(test->todo) {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns")) if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns"))
ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, L""), "got %s\n", wine_dbgstr_w(str));
else else
ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str));
}
SysFreeString(str); SysFreeString(str);
} }
else else
......
...@@ -263,9 +263,7 @@ static void test_namespaces_as_attributes(void) ...@@ -263,9 +263,7 @@ static void test_namespaces_as_attributes(void)
{ {
item = NULL; item = NULL;
hr = IXMLDOMNamedNodeMap_get_item(map, i, &item); hr = IXMLDOMNamedNodeMap_get_item(map, i, &item);
todo_wine_if(test->todo)
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (hr != S_OK) continue;
str = NULL; str = NULL;
hr = IXMLDOMNode_get_nodeName(item, &str); hr = IXMLDOMNode_get_nodeName(item, &str);
...@@ -277,8 +275,10 @@ static void test_namespaces_as_attributes(void) ...@@ -277,8 +275,10 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_prefix(item, &str); hr = IXMLDOMNode_get_prefix(item, &str);
if (test->prefixes[i]) if (test->prefixes[i])
{ {
todo_wine_if(test->todo) {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(!lstrcmpW(str, test->prefixes[i]), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, test->prefixes[i]), "got %s\n", wine_dbgstr_w(str));
}
SysFreeString(str); SysFreeString(str);
} }
else else
...@@ -294,12 +294,14 @@ static void test_namespaces_as_attributes(void) ...@@ -294,12 +294,14 @@ static void test_namespaces_as_attributes(void)
hr = IXMLDOMNode_get_namespaceURI(item, &str); hr = IXMLDOMNode_get_namespaceURI(item, &str);
if (test->uris[i]) if (test->uris[i])
{ {
todo_wine_if(test->todo) {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns")) if (test->prefixes[i] && !lstrcmpW(test->prefixes[i], L"xmlns"))
ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"), ok(!lstrcmpW(str, L"http://www.w3.org/2000/xmlns/"),
"got %s\n", wine_dbgstr_w(str)); "got %s\n", wine_dbgstr_w(str));
else else
ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str)); ok(!lstrcmpW(str, test->uris[i]), "got %s\n", wine_dbgstr_w(str));
}
SysFreeString(str); SysFreeString(str);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment