diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-02-12 08:12:12 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-02-12 08:12:12 -0800 |
commit | e94552c9ca883f8c4f2cead24355a60ecba0efb2 (patch) | |
tree | 0aa1f9ed3d61c110d458f4c044920bd5998460fe /tests | |
parent | 00b4b0192f88392e80f1c504526c7e73f4d16ec7 (diff) |
DOCTYPE parsing is now stackless
This prevents malformed input XML with very deeply recursive DOCTYPE sections
from crashing the parser.
Fixes #29.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_parse_doctype.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp index 14268f6..646ebbf 100644 --- a/tests/test_parse_doctype.cpp +++ b/tests/test_parse_doctype.cpp @@ -322,3 +322,43 @@ TEST(parse_doctype_error_ignore) CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE[")).status == status_bad_doctype); CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE["), parse_doctype).status == status_bad_doctype); } + +TEST(parse_doctype_stackless_group) +{ + std::basic_string<char_t> str; + + int count = 100000; + + str += "<!DOCTYPE "; + + for (int i = 0; i < count; ++i) + str += STR("<!G "); + + for (int j = 0; j < count; ++j) + str += STR(">"); + + str += ">"; + + xml_document doc; + CHECK(doc.load_string(str.c_str(), parse_fragment)); +} + +TEST(parse_doctype_stackless_ignore) +{ + std::basic_string<char_t> str; + + int count = 100000; + + str += "<!DOCTYPE "; + + for (int i = 0; i < count; ++i) + str += STR("<![IGNORE[ "); + + for (int j = 0; j < count; ++j) + str += STR("]]>"); + + str += ">"; + + xml_document doc; + CHECK(doc.load_string(str.c_str(), parse_fragment)); +} |