#20288: fix handling of invalid numeric charrefs in HTMLParser.
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 6a0e461..cde2bd2 100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -394,6 +394,12 @@
             ("data", "&#bad;"),
             ("endtag", "p"),
         ])
+        # add the [] as a workaround to avoid buffering (see #20288)
+        self._run_check(["<div>&#bad;</div>"], [
+            ("starttag", "div", []),
+            ("data", "&#bad;"),
+            ("endtag", "div"),
+        ])
 
     def test_unescape_function(self):
         parser = HTMLParser.HTMLParser()