mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
parser: Don't skip CR in xmlCurrentChar
Skip over carriage returns later in xmlNextChar.
This commit is contained in:
@@ -722,16 +722,24 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
|
|||||||
const unsigned char *cur;
|
const unsigned char *cur;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
|
cur = ctxt->input->cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 2.11 End-of-Line Handling
|
* 2.11 End-of-Line Handling
|
||||||
* the literal two-character sequence "#xD#xA" or a standalone
|
* the literal two-character sequence "#xD#xA" or a standalone
|
||||||
* literal #xD, an XML processor must pass to the application
|
* literal #xD, an XML processor must pass to the application
|
||||||
* the single character #xA.
|
* the single character #xA.
|
||||||
*/
|
*/
|
||||||
if (*(ctxt->input->cur) == '\n') {
|
if ((*cur == '\n') || (*cur == '\r')) {
|
||||||
ctxt->input->line++; ctxt->input->col = 1;
|
ctxt->input->line++;
|
||||||
} else
|
ctxt->input->col = 1;
|
||||||
|
if ((*cur == '\r') && (cur[1] == '\n')) {
|
||||||
|
ctxt->input->cur++;
|
||||||
|
cur++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
ctxt->input->col++;
|
ctxt->input->col++;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are supposed to handle UTF8, check it's valid
|
* We are supposed to handle UTF8, check it's valid
|
||||||
@@ -744,7 +752,6 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
|
|||||||
*
|
*
|
||||||
* Check for the 0x110000 limit too
|
* Check for the 0x110000 limit too
|
||||||
*/
|
*/
|
||||||
cur = ctxt->input->cur;
|
|
||||||
|
|
||||||
c = *cur;
|
c = *cur;
|
||||||
if (c & 0x80) {
|
if (c & 0x80) {
|
||||||
@@ -793,16 +800,25 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
|
|||||||
/* 1-byte code */
|
/* 1-byte code */
|
||||||
ctxt->input->cur++;
|
ctxt->input->cur++;
|
||||||
} else {
|
} else {
|
||||||
|
const unsigned char *cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assume it's a fixed length encoding (1) with
|
* Assume it's a fixed length encoding (1) with
|
||||||
* a compatible encoding for the ASCII set, since
|
* a compatible encoding for the ASCII set, since
|
||||||
* XML constructs only use < 128 chars
|
* XML constructs only use < 128 chars
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*(ctxt->input->cur) == '\n') {
|
cur = ctxt->input->cur;
|
||||||
ctxt->input->line++; ctxt->input->col = 1;
|
|
||||||
} else
|
if ((*cur == '\n') || (*cur == '\r')) {
|
||||||
|
ctxt->input->line++;
|
||||||
|
ctxt->input->col = 1;
|
||||||
|
if ((*cur == '\r') && (cur[1] == '\n')) {
|
||||||
|
ctxt->input->cur++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
ctxt->input->col++;
|
ctxt->input->col++;
|
||||||
|
}
|
||||||
ctxt->input->cur++;
|
ctxt->input->cur++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -953,7 +969,7 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
|
|||||||
}
|
}
|
||||||
if (*ctxt->input->cur == 0xD) {
|
if (*ctxt->input->cur == 0xD) {
|
||||||
if (ctxt->input->cur[1] == 0xA) {
|
if (ctxt->input->cur[1] == 0xA) {
|
||||||
ctxt->input->cur++;
|
*len = 2;
|
||||||
}
|
}
|
||||||
return(0xA);
|
return(0xA);
|
||||||
}
|
}
|
||||||
@@ -968,7 +984,7 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
|
|||||||
*len = 1;
|
*len = 1;
|
||||||
if (*ctxt->input->cur == 0xD) {
|
if (*ctxt->input->cur == 0xD) {
|
||||||
if (ctxt->input->cur[1] == 0xA) {
|
if (ctxt->input->cur[1] == 0xA) {
|
||||||
ctxt->input->cur++;
|
*len = 2;
|
||||||
}
|
}
|
||||||
return(0xA);
|
return(0xA);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user