summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--config.h.in5
-rw-r--r--debugXML.c30
-rw-r--r--include/libxml/xmlerror.h2
4 files changed, 35 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 25125af5..a4ec2b68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Oct 15 10:48:30 EDT 2004 Daniel Veillard <daniel@veillard.com>
+
+ * debugXML.c include/libxml/xmlerror.h: added UTF-8 string checking,
+ raise a problem, need debug
+
Wed Oct 13 02:17:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
* python/Makefile.am: applied patch from Thomas Fitzsimmons fixing
diff --git a/config.h.in b/config.h.in
index 8a652870..79739705 100644
--- a/config.h.in
+++ b/config.h.in
@@ -255,7 +255,7 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* Define to 1 if the C compiler supports function prototypes. */
+/* Define if compiler has function prototypes */
#undef PROTOTYPES
/* Determine what socket length (socklen_t) data type is */
@@ -273,9 +273,6 @@
/* Using the Win32 Socket implementation */
#undef _WINSOCKAPI_
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
-
/* Win32 Std C name mangling work-around */
#undef snprintf
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)");
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index e9e605e0..61a5ece3 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -777,7 +777,7 @@ typedef enum {
XML_CHECK_WRONG_PARENT,/* 5029 */
XML_CHECK_NS_SCOPE, /* 5030 */
XML_CHECK_NS_ANCESTOR, /* 5031 */
- XML_CHECK_ /* 5032 */
+ XML_CHECK_NOT_UTF8 /* 5032 */
#if 0
XML_CHECK_, /* 5033 */
XML_CHECK_X /* 503 */