From c76518c71d044f11847b8c6a03e8cf347a4cac31 Mon Sep 17 00:00:00 2001 From: Henri Sivonen Date: Mon, 22 Jun 2015 13:17:49 +0300 Subject: [PATCH] Add tests for integer overflow when a signed 32-bit integer is used for holding the numeric character reference value. --- tokenizer/numericEntities.test | 36 +++++++++++++++++ tree-construction/entities01.dat | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/tokenizer/numericEntities.test b/tokenizer/numericEntities.test index 36c82281..43de84b0 100644 --- a/tokenizer/numericEntities.test +++ b/tokenizer/numericEntities.test @@ -1,5 +1,41 @@ {"tests": [ +{"description": "Invalid unterminated numeric entity character overflow before EOF", +"input": "�", +"output": ["ParseError", "ParseError", ["Character", "\uFFFD"]]}, + +{"description": "Invalid unterminated numeric entity character overflow before EOF", +"input": "�", +"output": ["ParseError", "ParseError", ["Character", "\uFFFD"]]}, + +{"description": "Invalid unterminated numeric entity character overflow before EOF", +"input": "�", +"output": ["ParseError", "ParseError", ["Character", "\uFFFD"]]}, + +{"description": "Invalid unterminated numeric entity character overflow", +"input": "�x", +"output": ["ParseError", "ParseError", ["Character", "\uFFFDx"]]}, + +{"description": "Invalid unterminated numeric entity character overflow", +"input": "�x", +"output": ["ParseError", "ParseError", ["Character", "\uFFFDx"]]}, + +{"description": "Invalid unterminated numeric entity character overflow", +"input": "�x", +"output": ["ParseError", "ParseError", ["Character", "\uFFFDx"]]}, + +{"description": "Invalid numeric entity character overflow", +"input": "�", +"output": ["ParseError", ["Character", "\uFFFD"]]}, + +{"description": "Invalid numeric entity character overflow", +"input": "�", +"output": ["ParseError", ["Character", "\uFFFD"]]}, + +{"description": "Invalid numeric entity character overflow", +"input": "�", +"output": ["ParseError", ["Character", "\uFFFD"]]}, + {"description": "Invalid numeric entity character U+0000", "input": "�", "output": ["ParseError", ["Character", "\uFFFD"]]}, diff --git a/tree-construction/entities01.dat b/tree-construction/entities01.dat index 20d53a0f..b271f822 100644 --- a/tree-construction/entities01.dat +++ b/tree-construction/entities01.dat @@ -721,3 +721,72 @@ FOO�ZOO | | | "FOO�ZOO" + +#data +FOO� +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +(1,13): eof-in-numeric-entity +#document +| +| +| +| "FOO�" + +#data +FOO� +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +(1,13): eof-in-numeric-entity +#document +| +| +| +| "FOO�" + +#data +FOO� +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +(1,13): eof-in-numeric-entity +#document +| +| +| +| "FOO�" + +#data +FOO�ZOO +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +#document +| +| +| +| "FOO�ZOO" + +#data +FOO�ZOO +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +#document +| +| +| +| "FOO�ZOO" + +#data +FOO�ZOO +#errors +(1,3): expected-doctype-but-got-chars +(1,13): illegal-codepoint-for-numeric-entity +#document +| +| +| +| "FOO�ZOO"