1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +03:00

applied UTF-8 script parsing bug #310229 fix from Jiri Netolicky added the

* HTMLparser.c: applied UTF-8 script parsing bug #310229 fix from
  Jiri Netolicky
* result/HTML/script2.html* test/HTML/script2.html: added the test
  case from the regression suite
Daniel
This commit is contained in:
Daniel Veillard 2005-07-13 16:37:38 +00:00
parent 744acfffe5
commit 358fef4b1e
6 changed files with 96 additions and 6 deletions

View File

@ -1,3 +1,10 @@
Wed Jul 13 18:35:47 CEST 2005 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: applied UTF-8 script parsing bug #310229 fix from
Jiri Netolicky
* result/HTML/script2.html* test/HTML/script2.html: added the test
case from the regression suite
Tue Jul 12 17:08:11 CEST 2005 Daniel Veillard <daniel@veillard.com> Tue Jul 12 17:08:11 CEST 2005 Daniel Veillard <daniel@veillard.com>
* nanohttp.c: fixed bug #310105 with http_proxy environments with * nanohttp.c: fixed bug #310105 with http_proxy environments with

View File

@ -2629,10 +2629,10 @@ static void
htmlParseScript(htmlParserCtxtPtr ctxt) { htmlParseScript(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1]; xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1];
int nbchar = 0; int nbchar = 0;
xmlChar cur; int cur,l;
SHRINK; SHRINK;
cur = CUR; cur = CUR_CHAR(l);
while (IS_CHAR_CH(cur)) { while (IS_CHAR_CH(cur)) {
if ((cur == '<') && (NXT(1) == '!') && (NXT(2) == '-') && if ((cur == '<') && (NXT(1) == '!') && (NXT(2) == '-') &&
(NXT(3) == '-')) { (NXT(3) == '-')) {
@ -2648,7 +2648,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
} }
nbchar = 0; nbchar = 0;
htmlParseComment(ctxt); htmlParseComment(ctxt);
cur = CUR; cur = CUR_CHAR(l);
continue; continue;
} else if ((cur == '<') && (NXT(1) == '/')) { } else if ((cur == '<') && (NXT(1) == '/')) {
/* /*
@ -2661,7 +2661,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
((NXT(2) >= 'a') && (NXT(2) <= 'z'))) ((NXT(2) >= 'a') && (NXT(2) <= 'z')))
break; /* while */ break; /* while */
} }
buf[nbchar++] = cur; COPY_BUF(l,buf,nbchar,cur);
if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) { if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
if (ctxt->sax->cdataBlock!= NULL) { if (ctxt->sax->cdataBlock!= NULL) {
/* /*
@ -2673,8 +2673,8 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
} }
nbchar = 0; nbchar = 0;
} }
NEXT; NEXTL(l);
cur = CUR; cur = CUR_CHAR(l);
} }
if (!(IS_CHAR_CH(cur))) { if (!(IS_CHAR_CH(cur))) {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,

14
result/HTML/script2.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Page</title>
</head>
<body><div id="portal">
<script type="text/javascript">
documen.write("P&#345;&iacute;li&scaron; &#382;lu&#357;ou&#269;k&yacute; k&#367;&#328; &uacute;p&#283;l &#271;&aacute;belks&eacute; &oacute;dy");
</script><p>
P&#345;&iacute;li&scaron; &#382;lu&#357;ou&#269;k&yacute; k&#367;&#328; &uacute;p&#283;l &#271;&aacute;belks&eacute; &oacute;dy;
</p>
</div></body>
</html>

View File

View File

@ -0,0 +1,50 @@
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(html, -//W3C//DTD XHTML 1.0 Strict//EN, http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd)
SAX.startElement(html, xmlns='http://www.w3.org/1999/xhtml')
SAX.ignorableWhitespace(
, 2)
SAX.startElement(head)
SAX.ignorableWhitespace(
, 3)
SAX.startElement(meta, http-equiv='Content-Type', content='text/html; charset=UTF-8')
SAX.endElement(meta)
SAX.ignorableWhitespace(
, 1)
SAX.startElement(title)
SAX.characters(Test Page, 9)
SAX.endElement(title)
SAX.ignorableWhitespace(
, 1)
SAX.endElement(head)
SAX.ignorableWhitespace(
, 1)
SAX.startElement(body)
SAX.ignorableWhitespace(
, 1)
SAX.startElement(div, id='portal')
SAX.characters(
, 1)
SAX.startElement(script, type='text/javascript')
SAX.cdata(
documen.write("P&#345;, 74)
SAX.endElement(script)
SAX.characters(
, 2)
SAX.startElement(p)
SAX.characters(
P&#345;&iacute;li&scaron; , 58)
SAX.endElement(p)
SAX.characters(
, 1)
SAX.endElement(div)
SAX.ignorableWhitespace(
, 1)
SAX.endElement(body)
SAX.ignorableWhitespace(
, 1)
SAX.endElement(html)
SAX.ignorableWhitespace(
, 2)
SAX.endDocument()

19
test/HTML/script2.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test Page</title>
</head>
<body>
<div id="portal">
<script type="text/javascript">
documen.write("Příliš žluťoučký kůň úpěl ďábelksé ódy");
</script>
<p>
Příliš žluťoučký kůň úpěl ďábelksé ódy;
</p>
</div>
</body>
</html>