From 0ed261427d4f4e4f81b62816dc0d94bfacd0890b Mon Sep 17 00:00:00 2001 From: Michael Rees Date: Fri, 14 Apr 2017 22:52:58 -0700 Subject: [PATCH] Validate HTML string before beginning parsing --- src/HTMLParser/HTMLParser.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/HTMLParser/HTMLParser.cpp b/src/HTMLParser/HTMLParser.cpp index a63e523..08f7c05 100644 --- a/src/HTMLParser/HTMLParser.cpp +++ b/src/HTMLParser/HTMLParser.cpp @@ -1,3 +1,5 @@ +#include + #include "../HTMLElements/HTMLBodyElement.hpp" #include "../HTMLElements/HTMLTextElement.hpp" #include "../HTMLElements/HTMLParagraphElement.hpp" @@ -32,6 +34,9 @@ void HTMLParser::insert_html_element(const std::shared_ptr &element Document HTMLParser::construct_document_from_string(std::wstring &html) { + if (!tokenizer.is_valid_html_string(html)) + std::cerr << "ERROR: HTML string is not valid! " + "Bad things may happen." << std::endl; Document document = Document(); std::vector> tokens =