about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-08-15 18:20:58 +0200
committerbptato <nincsnevem662@gmail.com>2023-08-15 18:20:58 +0200
commit65ea34b21c32cbadc462968bfdb9993a5b5429c2 (patch)
treedbc89b42f97e4e0ed731e614803d8cd8ef8fa1fc
parentf73a6683469df17608af51a1e7e582615e43f972 (diff)
downloadchawan-65ea34b21c32cbadc462968bfdb9993a5b5429c2.tar.gz
Fix assertion on unexpected characters
In some cases, an unexpected character token could call
parseErrorByTokenType...
-rw-r--r--chame/htmlparser.nim2
-rw-r--r--chame/parseerror.nim1
2 files changed, 3 insertions, 0 deletions
diff --git a/chame/htmlparser.nim b/chame/htmlparser.nim
index afe96ef1..400b370d 100644
--- a/chame/htmlparser.nim
+++ b/chame/htmlparser.nim
@@ -1036,6 +1036,8 @@ proc parseErrorByTokenType(parser: var HTML5Parser, tokenType: TokenType) =
     parser.parseError UNEXPECTED_END_TAG
   of EOF:
     parser.parseError UNEXPECTED_EOF
+  of CHARACTER_ASCII, CHARACTER:
+    parser.parseError UNEXPECTED_CHARACTER
   else:
     doAssert false
 
diff --git a/chame/parseerror.nim b/chame/parseerror.nim
index d99b2fed..8e85ead1 100644
--- a/chame/parseerror.nim
+++ b/chame/parseerror.nim
@@ -68,3 +68,4 @@ type ParseError* = enum
   INVALID_TEXT_PARENT = "Invalid parent element for text node"
   NON_SPACE_TABLE_TEXT = "Non-space table text"
   UNEXPECTED_AFTER_BODY_TOKEN = "Unexpected token after body"
+  UNEXPECTED_CHARACTER = "Unexpected character token"