mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
fixed #99082 for xi:include encoding="..." support on text includes. added
* xinclude.c parserInternals.c encoding.c: fixed #99082 for xi:include encoding="..." support on text includes. * result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml test/XInclude/ents/isolatin.txt : added a specific regression test * python/generator.py python/libxml2class.txt: fixed the generator the new set of comments generated for doc/libxml2-api.xml were breaking the python generation. Daniel
This commit is contained in:
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
Wed Nov 20 14:24:56 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xinclude.c parserInternals.c encoding.c: fixed #99082
|
||||
for xi:include encoding="..." support on text includes.
|
||||
* result/XInclude/tstencoding.xml test/XInclude/docs/tstencoding.xml
|
||||
test/XInclude/ents/isolatin.txt : added a specific regression test
|
||||
* python/generator.py python/libxml2class.txt: fixed the generator
|
||||
the new set of comments generated for doc/libxml2-api.xml were
|
||||
breaking the python generation.
|
||||
|
||||
Tue Nov 19 23:25:47 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* doc/Makefile.am: repair some problem if gtk-doc fail or such
|
||||
|
@ -2120,7 +2120,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
|
||||
*/
|
||||
if (ret == -3)
|
||||
ret = 0;
|
||||
return (ret);
|
||||
return (written);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1436,10 +1436,12 @@ xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
|
||||
ctxt->sax->error(ctxt->userData,
|
||||
"Char 0x%X out of allowed range\n",
|
||||
val);
|
||||
if (ctxt != NULL) {
|
||||
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
||||
ctxt->wellFormed = 0;
|
||||
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
|
||||
}
|
||||
}
|
||||
return (val);
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
|
@ -746,7 +746,7 @@ def writeDoc(name, args, indent, output):
|
||||
output.write('\n ');
|
||||
output.write(indent)
|
||||
output.write(val);
|
||||
output.write('"""\n')
|
||||
output.write(' """\n')
|
||||
|
||||
def buildWrappers():
|
||||
global ctypes
|
||||
|
@ -150,6 +150,13 @@ validateNamesValue()
|
||||
validateNmtokenValue()
|
||||
validateNmtokensValue()
|
||||
|
||||
# functions from module wincecompat
|
||||
close()
|
||||
getenv()
|
||||
read()
|
||||
strerror()
|
||||
write()
|
||||
|
||||
# functions from module xmlIO
|
||||
checkFilename()
|
||||
cleanupInputCallbacks()
|
||||
@ -302,7 +309,7 @@ uCSIsUnifiedCanadianAboriginalSyllabics()
|
||||
uCSIsYiRadicals()
|
||||
uCSIsYiSyllables()
|
||||
|
||||
# functions from module xmlversion
|
||||
# functions from module xmlwin32version
|
||||
checkVersion()
|
||||
|
||||
# functions from module xpathInternals
|
||||
|
6
result/XInclude/tstencoding.xml
Normal file
6
result/XInclude/tstencoding.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||
<!-- Simple test of including another text document -->
|
||||
test with accents in ISO-8859-1: <20> <20> <20> <20>
|
||||
|
||||
</x>
|
5
test/XInclude/docs/tstencoding.xml
Normal file
5
test/XInclude/docs/tstencoding.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
|
||||
<!-- Simple test of including another text document -->
|
||||
<xinclude:include href="../ents/isolatin.txt" encoding="ISO-8859-1" parse="text"/>
|
||||
</x>
|
1
test/XInclude/ents/isolatin.txt
Normal file
1
test/XInclude/ents/isolatin.txt
Normal file
@ -0,0 +1 @@
|
||||
test with accents in ISO-8859-1: <20> <20> <20> <20>
|
50
xinclude.c
50
xinclude.c
@ -25,6 +25,7 @@
|
||||
#include <libxml/xpointer.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/globals.h>
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
@ -37,6 +38,7 @@
|
||||
#define XINCLUDE_PARSE (const xmlChar *) "parse"
|
||||
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
|
||||
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
|
||||
#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
|
||||
|
||||
/* #define DEBUG_XINCLUDE */
|
||||
#ifdef DEBUG_XINCLUDE
|
||||
@ -1106,6 +1108,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||
xmlURIPtr uri;
|
||||
xmlChar *URL;
|
||||
int i;
|
||||
xmlChar *encoding = NULL;
|
||||
xmlCharEncoding enc = 0;
|
||||
|
||||
/*
|
||||
* Check the URL and remove any fragment identifier
|
||||
*/
|
||||
@ -1151,10 +1156,33 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Load it.
|
||||
* Issue 62: how to detect the encoding
|
||||
* Try to get the encoding if available
|
||||
*/
|
||||
buf = xmlParserInputBufferCreateFilename((const char *)URL, 0);
|
||||
if ((ctxt->incTab[nr] != NULL) && (ctxt->incTab[nr]->ref != NULL)) {
|
||||
encoding = xmlGetProp(ctxt->incTab[nr]->ref, XINCLUDE_PARSE_ENCODING);
|
||||
}
|
||||
if (encoding != NULL) {
|
||||
/*
|
||||
* TODO: we should not have to remap to the xmlCharEncoding
|
||||
* predefined set, a better interface than
|
||||
* xmlParserInputBufferCreateFilename should allow any
|
||||
* encoding supported by iconv
|
||||
*/
|
||||
enc = xmlParseCharEncoding((const char *) encoding);
|
||||
if (enc == XML_CHAR_ENCODING_ERROR) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: encoding %s not supported\n", encoding);
|
||||
xmlFree(encoding);
|
||||
xmlFree(URL);
|
||||
return(-1);
|
||||
}
|
||||
xmlFree(encoding);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load it.
|
||||
*/
|
||||
buf = xmlParserInputBufferCreateFilename((const char *)URL, enc);
|
||||
if (buf == NULL) {
|
||||
xmlFree(URL);
|
||||
return(-1);
|
||||
@ -1170,16 +1198,18 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||
|
||||
content = xmlBufferContent(buf->buffer);
|
||||
len = xmlBufferLength(buf->buffer);
|
||||
for (i = 0;i < len; i++) {
|
||||
/*
|
||||
* TODO: if the encoding issue is solved, scan UTF8 chars instead
|
||||
*/
|
||||
if (!IS_CHAR(content[i])) {
|
||||
for (i = 0;i < len;) {
|
||||
int cur;
|
||||
int l;
|
||||
|
||||
cur = xmlStringCurrentChar(NULL, &content[i], &l);
|
||||
if (!IS_CHAR(cur)) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"XInclude: %s contains invalid char %d\n", URL, content[i]);
|
||||
"XInclude: %s contains invalid char %d\n", URL, cur);
|
||||
} else {
|
||||
xmlNodeAddContentLen(node, &content[i], 1);
|
||||
xmlNodeAddContentLen(node, &content[i], l);
|
||||
}
|
||||
i += l;
|
||||
}
|
||||
xmlBufferShrink(buf->buffer, len);
|
||||
}
|
||||
|
Reference in New Issue
Block a user