diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2004-10-15 14:50:10 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2004-10-15 14:50:10 +0000 |
commit | c6095788c42bd107fbf9c377c69bfa63f0b4934c (patch) | |
tree | 2b708f9b1c4f9b9057140b55842abf7fbff2e9a7 /debugXML.c | |
parent | 43b8e5790c8d2e07d0bd1d07c925f25a8dbf9f42 (diff) | |
download | libxml2-c6095788c42bd107fbf9c377c69bfa63f0b4934c.tar.gz |
added UTF-8 string checking, raise a problem, need debug Daniel
* debugXML.c include/libxml/xmlerror.h: added UTF-8 string checking,
raise a problem, need debug
Daniel
Diffstat (limited to 'debugXML.c')
-rw-r--r-- | debugXML.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -164,7 +164,7 @@ xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra) msg, extra); } static void -xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, char *extra) +xmlDebugErr3(xmlDebugCtxtPtr ctxt, int error, const char *msg, const char *extra) { ctxt->errors++; __xmlRaiseError(NULL, NULL, NULL, @@ -208,6 +208,25 @@ xmlCtxtNsCheckScope(xmlDebugCtxtPtr ctxt, xmlNodePtr node, xmlNsPtr ns) } } +/** + * xmlCtxtCheckString: + * @ctxt: the debug context + * @str: the string + * + * Do debugging on the string, currently it just checks the UTF-8 content + */ +static void +xmlCtxtCheckString(xmlDebugCtxtPtr ctxt, const xmlChar * str) +{ + if (str == NULL) return; + if (ctxt->check) { + if (!xmlCheckUTF8(str)) { + xmlDebugErr3(ctxt, XML_CHECK_NOT_DTD, + "String is not UTF-8 %s", (const char *) str); + } + } +} + static void xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) { if (node->parent == NULL) @@ -263,6 +282,12 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) { xmlCtxtNsCheckScope(ctxt, node, node->ns); } + if ((node->type != XML_ELEMENT_NODE) && + (node->type != XML_HTML_DOCUMENT_NODE) && + (node->type != XML_DOCUMENT_NODE)) { + if (node->content != NULL) + xmlCtxtCheckString(ctxt, (const char *) node->content); + } } static void @@ -270,8 +295,9 @@ xmlCtxtDumpString(xmlDebugCtxtPtr ctxt, const xmlChar * str) { int i; - if (ctxt->check) + if (ctxt->check) { return; + } /* TODO: check UTF8 content of the string */ if (str == NULL) { fprintf(ctxt->output, "(NULL)"); |