1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +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:
Daniel Veillard
2002-11-20 13:28:31 +00:00
parent 817e70b6ac
commit d076a20ea6
9 changed files with 77 additions and 16 deletions

View File

@ -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> 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 * doc/Makefile.am: repair some problem if gtk-doc fail or such

View File

@ -2120,7 +2120,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
*/ */
if (ret == -3) if (ret == -3)
ret = 0; ret = 0;
return (ret); return (written);
} }
/** /**

View File

@ -1436,9 +1436,11 @@ xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
ctxt->sax->error(ctxt->userData, ctxt->sax->error(ctxt->userData,
"Char 0x%X out of allowed range\n", "Char 0x%X out of allowed range\n",
val); val);
ctxt->errNo = XML_ERR_INVALID_ENCODING; if (ctxt != NULL) {
ctxt->wellFormed = 0; ctxt->errNo = XML_ERR_INVALID_ENCODING;
if (ctxt->recovery == 0) ctxt->disableSAX = 1; ctxt->wellFormed = 0;
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
}
} }
return (val); return (val);
} else { } else {

View File

@ -746,7 +746,7 @@ def writeDoc(name, args, indent, output):
output.write('\n '); output.write('\n ');
output.write(indent) output.write(indent)
output.write(val); output.write(val);
output.write('"""\n') output.write(' """\n')
def buildWrappers(): def buildWrappers():
global ctypes global ctypes

View File

@ -150,6 +150,13 @@ validateNamesValue()
validateNmtokenValue() validateNmtokenValue()
validateNmtokensValue() validateNmtokensValue()
# functions from module wincecompat
close()
getenv()
read()
strerror()
write()
# functions from module xmlIO # functions from module xmlIO
checkFilename() checkFilename()
cleanupInputCallbacks() cleanupInputCallbacks()
@ -302,7 +309,7 @@ uCSIsUnifiedCanadianAboriginalSyllabics()
uCSIsYiRadicals() uCSIsYiRadicals()
uCSIsYiSyllables() uCSIsYiSyllables()
# functions from module xmlversion # functions from module xmlwin32version
checkVersion() checkVersion()
# functions from module xpathInternals # functions from module xpathInternals

View 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>

View 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>

View File

@ -0,0 +1 @@
test with accents in ISO-8859-1: <20> <20> <20> <20>

View File

@ -25,6 +25,7 @@
#include <libxml/xpointer.h> #include <libxml/xpointer.h>
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/encoding.h>
#include <libxml/globals.h> #include <libxml/globals.h>
#ifdef LIBXML_XINCLUDE_ENABLED #ifdef LIBXML_XINCLUDE_ENABLED
@ -37,6 +38,7 @@
#define XINCLUDE_PARSE (const xmlChar *) "parse" #define XINCLUDE_PARSE (const xmlChar *) "parse"
#define XINCLUDE_PARSE_XML (const xmlChar *) "xml" #define XINCLUDE_PARSE_XML (const xmlChar *) "xml"
#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" #define XINCLUDE_PARSE_TEXT (const xmlChar *) "text"
#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding"
/* #define DEBUG_XINCLUDE */ /* #define DEBUG_XINCLUDE */
#ifdef DEBUG_XINCLUDE #ifdef DEBUG_XINCLUDE
@ -1106,6 +1108,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlURIPtr uri; xmlURIPtr uri;
xmlChar *URL; xmlChar *URL;
int i; int i;
xmlChar *encoding = NULL;
xmlCharEncoding enc = 0;
/* /*
* Check the URL and remove any fragment identifier * Check the URL and remove any fragment identifier
*/ */
@ -1151,10 +1156,33 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
} }
} }
/* /*
* Load it. * Try to get the encoding if available
* Issue 62: how to detect the encoding
*/ */
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) { if (buf == NULL) {
xmlFree(URL); xmlFree(URL);
return(-1); return(-1);
@ -1170,16 +1198,18 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
content = xmlBufferContent(buf->buffer); content = xmlBufferContent(buf->buffer);
len = xmlBufferLength(buf->buffer); len = xmlBufferLength(buf->buffer);
for (i = 0;i < len; i++) { for (i = 0;i < len;) {
/* int cur;
* TODO: if the encoding issue is solved, scan UTF8 chars instead int l;
*/
if (!IS_CHAR(content[i])) { cur = xmlStringCurrentChar(NULL, &content[i], &l);
if (!IS_CHAR(cur)) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"XInclude: %s contains invalid char %d\n", URL, content[i]); "XInclude: %s contains invalid char %d\n", URL, cur);
} else { } else {
xmlNodeAddContentLen(node, &content[i], 1); xmlNodeAddContentLen(node, &content[i], l);
} }
i += l;
} }
xmlBufferShrink(buf->buffer, len); xmlBufferShrink(buf->buffer, len);
} }