taskschd: Return appropriate error code for a malformed XML.

oldstable
Dmitry Timoshkov 2014-02-25 12:22:36 +09:00 committed by Alexandre Julliard
parent 39f0b276c7
commit 4c08276e6b
2 changed files with 13 additions and 6 deletions

View File

@ -1916,7 +1916,7 @@ static HRESULT read_settings(IXmlReader *reader, ITaskSettings *taskset)
}
WARN("Settings was not terminated\n");
return E_FAIL;
return SCHED_E_MALFORMEDXML;
}
static HRESULT read_registration_info(IXmlReader *reader, IRegistrationInfo *info)
@ -1981,7 +1981,7 @@ static HRESULT read_registration_info(IXmlReader *reader, IRegistrationInfo *inf
}
WARN("RegistrationInfo was not terminated\n");
return E_FAIL;
return SCHED_E_MALFORMEDXML;
}
static HRESULT read_task_attributes(IXmlReader *reader, ITaskDefinition *taskdef)
@ -2119,7 +2119,7 @@ static HRESULT read_task(IXmlReader *reader, ITaskDefinition *taskdef)
}
WARN("Task was not terminated\n");
return E_FAIL;
return SCHED_E_MALFORMEDXML;
}
static HRESULT read_xml(IXmlReader *reader, ITaskDefinition *taskdef)
@ -2165,7 +2165,7 @@ static HRESULT read_xml(IXmlReader *reader, ITaskDefinition *taskdef)
}
WARN("Task definition was not found\n");
return E_FAIL;
return SCHED_E_MALFORMEDXML;
}
static HRESULT WINAPI TaskDefinition_put_XmlText(ITaskDefinition *iface, BSTR xml)

View File

@ -1153,8 +1153,12 @@ static void test_TaskDefinition(void)
static const char xml6[] =
"<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
" <RegistrationInfo/>\n"
" <Settings/>\n"
" <Actions>\n"
" <Exec>\n"
" <Command>\"task1.exe\"</Command>\n"
" </Exec>\n"
" </Actions>\n"
" <Settings>\n"
"</Task>\n";
static const char xml7[] =
"<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
@ -1241,13 +1245,16 @@ todo_wine
MultiByteToWideChar(CP_ACP, 0, xml6, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0]));
hr = ITaskDefinition_put_XmlText(taskdef, xmlW);
todo_wine
ok(hr == SCHED_E_MALFORMEDXML, "expected SCHED_E_MALFORMEDXML, got %#x\n", hr);
MultiByteToWideChar(CP_ACP, 0, xml7, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0]));
hr = ITaskDefinition_put_XmlText(taskdef, xmlW);
ok(hr == SCHED_E_INVALIDVALUE, "expected SCHED_E_INVALIDVALUE, got %#x\n", hr);
xmlW[0] = 0;
hr = ITaskDefinition_put_XmlText(taskdef, xmlW);
ok(hr == SCHED_E_MALFORMEDXML, "expected SCHED_E_MALFORMEDXML, got %#x\n", hr);
ITaskDefinition_Release(taskdef);
ITaskService_Release(service);
}