diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-15 20:12:11 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-15 20:12:11 +0200 |
commit | dc934380de353d16ff62c633ff949fb85b30fd13 (patch) | |
tree | b831b0633da44cf059b735ae8b2f0c4f9e311a88 /src/html | |
parent | 9aa9ecd2d2c5048ac3057aeee28b1e42ce4be0d8 (diff) | |
download | chawan-dc934380de353d16ff62c633ff949fb85b30fd13.tar.gz |
htmlparser: check required callbacks
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/htmlparser.nim | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/html/htmlparser.nim b/src/html/htmlparser.nim index e72f897e..442068ad 100644 --- a/src/html/htmlparser.nim +++ b/src/html/htmlparser.nim @@ -2671,10 +2671,23 @@ proc bomSniff(inputStream: Stream): Charset = else: inputStream.setPosition(0) +# Any of these pointers being nil would later result in a crash. +proc checkCallbacks(dombuilder: DOMBuilder) = + doAssert dombuilder.getTemplateContent != nil + doAssert dombuilder.getParentNode != nil + doAssert dombuilder.getLocalName != nil + doAssert dombuilder.createElement != nil + doAssert dombuilder.createComment != nil + doAssert dombuilder.createDocumentType != nil + doAssert dombuilder.insertBefore != nil + doAssert dombuilder.insertText != nil + doAssert dombuilder.remove != nil + proc parseHTML*[Handle](inputStream: Stream, dombuilder: DOMBuilder[Handle], opts: HTML5ParserOpts[Handle]) = ## Parse an HTML document, using the DOMBuilder object `dombuilder`, and ## parser options `opts`. + dombuilder.checkCallbacks() var charsetStack: seq[Charset] for i in countdown(opts.charsets.high, 0): charsetStack.add(opts.charsets[i]) |