Commit fa591d3c authored by David Kahurani's avatar David Kahurani Committed by Alexandre Julliard

xmllite/writer: Properly validate DocType name.

Current code skips a character and goes on to run is_namechar the next instead of the current character ultimately always running a null string on is_namechar and therefore always returning error on multi-character strings Signed-off-by: 's avatarDavid Kahurani <k.kahurani@gmail.com>
parent b402ce89
......@@ -2145,6 +2145,14 @@ static void test_WriteDocType(void)
hr = IXmlWriter_WriteDocType(writer, L"a", pubidW, NULL, NULL);
ok(hr == WC_E_PUBLICID, "Unexpected hr %#lx.\n", hr);
/* Invalid multi-character string */
hr = IXmlWriter_WriteDocType(writer, L":ax>m", NULL, NULL, NULL);
ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
/* Valid multi-character string */
hr = IXmlWriter_WriteDocType(writer, L"root", NULL, NULL, NULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IStream_Release(stream);
for (i = 0; i < ARRAY_SIZE(doctype_tests); i++)
......
......@@ -376,11 +376,12 @@ static HRESULT is_valid_name(const WCHAR *str, unsigned int *out)
if (!is_namestartchar(*str++))
return WC_E_NAMECHARACTER;
while (*str++)
while (*str)
{
if (!is_namechar(*str))
return WC_E_NAMECHARACTER;
len++;
str++;
}
*out = len;
......
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