mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-14 20:01:04 +03:00
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
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
30
debugXML.c
30
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)");
|
||||
|
@ -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 */
|
||||
|
Reference in New Issue
Block a user