summaryrefslogtreecommitdiff
path: root/debugXML.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2004-10-15 14:50:10 +0000
committerDaniel Veillard <veillard@src.gnome.org>2004-10-15 14:50:10 +0000
commitc6095788c42bd107fbf9c377c69bfa63f0b4934c (patch)
tree2b708f9b1c4f9b9057140b55842abf7fbff2e9a7 /debugXML.c
parent43b8e5790c8d2e07d0bd1d07c925f25a8dbf9f42 (diff)
downloadlibxml2-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.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/debugXML.c b/debugXML.c
index 37284700..9b7163d1 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -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)");