mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-02-22 21:57:21 +03:00
- parser.c: fixed UTF8 BOM support in push mode
- test/utf8bom.xml result/utf8bom.xml result/noent/utf8bom.xml: added a specific testcase Daniel
This commit is contained in:
parent
3e5bb8e54e
commit
0e4cd17b61
@ -1,3 +1,9 @@
|
||||
Thu Jun 28 14:11:28 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* parser.c: fixed UTF8 BOM support in push mode
|
||||
* test/utf8bom.xml result/utf8bom.xml result/noent/utf8bom.xml:
|
||||
added a specific testcase
|
||||
|
||||
Wed Jun 27 18:33:13 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||
|
||||
* Makefile.am: added --push regression tests
|
||||
|
29
parser.c
29
parser.c
@ -7632,12 +7632,32 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
||||
*/
|
||||
goto done;
|
||||
case XML_PARSER_START:
|
||||
if (ctxt->charset == XML_CHAR_ENCODING_NONE) {
|
||||
xmlChar start[4];
|
||||
xmlCharEncoding enc;
|
||||
|
||||
/*
|
||||
* Very first chars read from the document flow.
|
||||
*/
|
||||
if (avail < 2)
|
||||
if (avail < 4)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Get the 4 first bytes and decode the charset
|
||||
* if enc != XML_CHAR_ENCODING_NONE
|
||||
* plug some encoding conversion routines.
|
||||
*/
|
||||
start[0] = RAW;
|
||||
start[1] = NXT(1);
|
||||
start[2] = NXT(2);
|
||||
start[3] = NXT(3);
|
||||
enc = xmlDetectCharEncoding(start, 4);
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cur = ctxt->input->cur[0];
|
||||
next = ctxt->input->cur[1];
|
||||
if (cur == 0) {
|
||||
@ -8509,9 +8529,6 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
inputStream->cur = inputStream->buf->buffer->content;
|
||||
inputStream->end =
|
||||
&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
|
||||
inputPush(ctxt, inputStream);
|
||||
|
||||
@ -8523,6 +8540,10 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
#endif
|
||||
}
|
||||
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
|
||||
return(ctxt);
|
||||
}
|
||||
|
||||
|
2
result/noent/utf8bom.xml
Normal file
2
result/noent/utf8bom.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<foo/>
|
2
result/utf8bom.xml
Normal file
2
result/utf8bom.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0"?>
|
||||
<foo/>
|
1
test/utf8bom.xml
Normal file
1
test/utf8bom.xml
Normal file
@ -0,0 +1 @@
|
||||
<foo/>
|
Loading…
x
Reference in New Issue
Block a user