From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/reader.c | 11 +++++++---- dlls/xmllite/tests/writer.c | 11 ++++------- dlls/xmllite/writer.c | 5 ++++- dlls/xmllite/xmllite_private.h | 1 + 4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index 1e146493aa6..27d4fd014c1 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -83,8 +83,6 @@ typedef enum StringValue_Last } XmlReaderStringValue;
-BOOL is_namestartchar(WCHAR ch); - static const char *debugstr_nodetype(XmlNodeType nodetype) { static const char * const type_names[] = @@ -1480,9 +1478,9 @@ BOOL is_pubchar(WCHAR ch) (ch == '_') || (ch == '\r') || (ch == '\n'); }
-BOOL is_namestartchar(WCHAR ch) +BOOL is_ncnamestartchar(WCHAR ch) { - return (ch == ':') || (ch >= 'A' && ch <= 'Z') || + return (ch >= 'A' && ch <= 'Z') || (ch == '_') || (ch >= 'a' && ch <= 'z') || (ch >= 0xc0 && ch <= 0xd6) || (ch >= 0xd8 && ch <= 0xf6) || @@ -1499,6 +1497,11 @@ BOOL is_namestartchar(WCHAR ch) (ch >= 0xfdf0 && ch <= 0xfffd); }
+BOOL is_namestartchar(WCHAR ch) +{ + return is_ncnamestartchar(ch) || ch == ':'; +} + /* [4 NS] NCName ::= Name - (Char* ':' Char*) */ BOOL is_ncnamechar(WCHAR ch) { diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 021ac35da18..0fae2bbca88 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -987,7 +987,6 @@ static void test_WriteStartElement(void) stream = writer_set_output(writer);
hr = IXmlWriter_WriteStartElement(writer, NULL, L".a", NULL); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartElement(writer, NULL, L":a", NULL); @@ -997,7 +996,6 @@ static void test_WriteStartElement(void) ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartElement(writer, L".prefix", L"a", L"uri"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteStartElement(writer, L":prefix", L"a", L"uri"); @@ -1015,7 +1013,7 @@ static void test_WriteStartElement(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, "<a"); + CHECK_OUTPUT(stream, "<a");
hr = IXmlWriter_WriteStartDocument(writer, XmlStandalone_Yes); ok(hr == WR_E_INVALIDACTION, "Unexpected hr %#lx.\n", hr); @@ -1734,10 +1732,10 @@ static void test_WriteAttributeString(void) { NULL, L"xmlns", L"uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, { L"xmlns", NULL, L"uri", NULL, "<e />", "<e", WR_E_XMLNSPREFIXDECLARATION, 0, 0, 1 }, { L"pre:fix", L"local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, - { L".prefix", L"local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER, 1, 1, 1 }, + { L".prefix", L"local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, { L"pre:fix", NULL, L"uri", L"b", "<e />", "<e", E_INVALIDARG }, { L"prefix", L"lo:cal", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, - { L"prefix", L".local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER, 1, 1, 1 }, + { L"prefix", L".local", L"uri", L"b", "<e />", "<e", WC_E_NAMECHARACTER }, { L"xmlns", NULL, NULL, L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, { L"xmlns", NULL, L"", L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, { L"xmlns", L"", NULL, L"uri", "<e />", "<e", WR_E_NSPREFIXDECLARED }, @@ -3354,7 +3352,6 @@ static void test_WriteQualifiedName(void)
/* Wrong start char */ hr = IXmlWriter_WriteQualifiedName(writer, L".a", L"cd"); - todo_wine ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr);
hr = IXmlWriter_WriteQualifiedName(writer, L":a", L"cd"); @@ -3363,7 +3360,7 @@ static void test_WriteQualifiedName(void) hr = IXmlWriter_Flush(writer); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
- CHECK_OUTPUT_TODO(stream, + CHECK_OUTPUT(stream, "<ab:a");
IStream_Release(stream); diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index c7dcafda875..6e343d0ade6 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -347,13 +347,16 @@ static struct ns *writer_find_ns(const xmlwriter *writer, const WCHAR *prefix, c
static HRESULT is_valid_ncname(const WCHAR *str, int *out) { - int len = 0; + int len = 1;
*out = 0;
if (!str || !*str) return S_OK;
+ if (!is_ncnamestartchar(*str++)) + return WC_E_NAMECHARACTER; + while (*str) { if (!is_ncnamechar(*str)) diff --git a/dlls/xmllite/xmllite_private.h b/dlls/xmllite/xmllite_private.h index fc3e6d264e1..16336ff7eb9 100644 --- a/dlls/xmllite/xmllite_private.h +++ b/dlls/xmllite/xmllite_private.h @@ -61,6 +61,7 @@ xml_encoding get_encoding_from_codepage(UINT); BOOL is_ncnamechar(WCHAR ch); BOOL is_pubchar(WCHAR ch); BOOL is_namestartchar(WCHAR ch); +BOOL is_ncnamestartchar(WCHAR ch); BOOL is_namechar(WCHAR ch);
/* [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] */