[libxml2] Add test cases for bug 758518
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxml2] Add test cases for bug 758518
- Date: Mon, 12 Jun 2017 17:57:34 +0000 (UTC)
commit 85c112a0828a13aadf9fa806a38dfb185e1ddd4c
Author: David Kilzer <ddkilzer apple com>
Date: Mon Jun 12 18:26:11 2017 +0200
Add test cases for bug 758518
test/HTML/758518-entity.html exposed a bug in pushParseTest() in
runtest.c which assumed that an input file was at least 4 bytes long.
That test case is only 3 bytes, so we now take the minimum of 4 bytes
or the length of the test input. We also now use 'chunkSize' in place
of the hard-coded value '1024' later in the function.
result/HTML/758518-entity.html | 2 ++
result/HTML/758518-entity.html.err | 3 +++
result/HTML/758518-entity.html.sax | 12 ++++++++++++
result/HTML/758518-tag.html | 2 ++
result/HTML/758518-tag.html.err | 3 +++
result/HTML/758518-tag.html.sax | 10 ++++++++++
runtest.c | 19 ++++++++++++-------
test/HTML/758518-entity.html | 1 +
test/HTML/758518-tag.html | 1 +
9 files changed, 46 insertions(+), 7 deletions(-)
---
diff --git a/result/HTML/758518-entity.html b/result/HTML/758518-entity.html
new file mode 100644
index 0000000..e72b0cb
--- /dev/null
+++ b/result/HTML/758518-entity.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>&Ù</p></body></html>
diff --git a/result/HTML/758518-entity.html.err b/result/HTML/758518-entity.html.err
new file mode 100644
index 0000000..0186677
--- /dev/null
+++ b/result/HTML/758518-entity.html.err
@@ -0,0 +1,3 @@
+./test/HTML/758518-entity.html:1: HTML parser error : htmlParseEntityRef: expecting ';'
+Ù
+ ^
diff --git a/result/HTML/758518-entity.html.sax b/result/HTML/758518-entity.html.sax
new file mode 100644
index 0000000..3d017ab
--- /dev/null
+++ b/result/HTML/758518-entity.html.sax
@@ -0,0 +1,12 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.error: htmlParseEntityRef: expecting ';'
+SAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(&, 1)
+SAX.characters(Ù, 2)
+SAX.endElement(p)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/result/HTML/758518-tag.html b/result/HTML/758518-tag.html
new file mode 100644
index 0000000..f99f421
--- /dev/null
+++ b/result/HTML/758518-tag.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html><body><p>“</p></body></html>
diff --git a/result/HTML/758518-tag.html.err b/result/HTML/758518-tag.html.err
new file mode 100644
index 0000000..c912c91
--- /dev/null
+++ b/result/HTML/758518-tag.html.err
@@ -0,0 +1,3 @@
+./test/HTML/758518-tag.html:1: HTML parser error : PI is not started correctly
+
+^
diff --git a/result/HTML/758518-tag.html.sax b/result/HTML/758518-tag.html.sax
new file mode 100644
index 0000000..fd4aa94
--- /dev/null
+++ b/result/HTML/758518-tag.html.sax
@@ -0,0 +1,10 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.error: PI is not started correctlySAX.startElement(html)
+SAX.startElement(body)
+SAX.startElement(p)
+SAX.characters(“, 2)
+SAX.endElement(p)
+SAX.endElement(body)
+SAX.endElement(html)
+SAX.endDocument()
diff --git a/runtest.c b/runtest.c
index 378b38e..dcf1405 100644
--- a/runtest.c
+++ b/runtest.c
@@ -1854,6 +1854,7 @@ pushParseTest(const char *filename, const char *result,
const char *base;
int size, res;
int cur = 0;
+ int chunkSize = 4;
nb_tests++;
/*
@@ -1864,17 +1865,21 @@ pushParseTest(const char *filename, const char *result,
return(-1);
}
+ if (chunkSize > size)
+ chunkSize = size;
+
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
- ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
+ ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename,
XML_CHAR_ENCODING_NONE);
else
#endif
- ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename);
+ ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, chunkSize, filename);
xmlCtxtUseOptions(ctxt, options);
- cur += 4;
+ cur += chunkSize;
+ chunkSize = 1024;
do {
- if (cur + 1024 >= size) {
+ if (cur + chunkSize >= size) {
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
htmlParseChunk(ctxt, base + cur, size - cur, 1);
@@ -1885,11 +1890,11 @@ pushParseTest(const char *filename, const char *result,
} else {
#ifdef LIBXML_HTML_ENABLED
if (options & XML_PARSE_HTML)
- htmlParseChunk(ctxt, base + cur, 1024, 0);
+ htmlParseChunk(ctxt, base + cur, chunkSize, 0);
else
#endif
- xmlParseChunk(ctxt, base + cur, 1024, 0);
- cur += 1024;
+ xmlParseChunk(ctxt, base + cur, chunkSize, 0);
+ cur += chunkSize;
}
} while (cur < size);
doc = ctxt->myDoc;
diff --git a/test/HTML/758518-entity.html b/test/HTML/758518-entity.html
new file mode 100644
index 0000000..d31c8ff
--- /dev/null
+++ b/test/HTML/758518-entity.html
@@ -0,0 +1 @@
+&j�
\ No newline at end of file
diff --git a/test/HTML/758518-tag.html b/test/HTML/758518-tag.html
new file mode 100644
index 0000000..935e752
--- /dev/null
+++ b/test/HTML/758518-tag.html
@@ -0,0 +1 @@
+<?a�
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]