diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp index 2fb6918..c9c40e2 100644 --- a/src/pugiconfig.hpp +++ b/src/pugiconfig.hpp @@ -40,6 +40,9 @@ // #define PUGIXML_MEMORY_OUTPUT_STACK 10240 // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 +// Tune this constant to adjust max nesting for XPath queries +// #define PUGIXML_XPATH_DEPTH_LIMIT 1024 + // Uncomment this to switch to header-only version // #define PUGIXML_HEADER_ONLY diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 34e126f..e166458 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -11147,7 +11147,7 @@ PUGI__NS_BEGIN #ifdef PUGIXML_XPATH_DEPTH_LIMIT PUGIXML_XPATH_DEPTH_LIMIT #else - 4096 + 1024 #endif ; diff --git a/tests/test_xpath_parse.cpp b/tests/test_xpath_parse.cpp index 89c66a3..d0b0bac 100644 --- a/tests/test_xpath_parse.cpp +++ b/tests/test_xpath_parse.cpp @@ -394,7 +394,7 @@ static std::basic_string rep(const std::basic_string& base, size TEST(xpath_parse_depth_limit) { - const size_t limit = 5000; + const size_t limit = 1500; CHECK_XPATH_FAIL((rep(STR("("), limit) + STR("1") + rep(STR(")"), limit)).c_str()); CHECK_XPATH_FAIL((STR("(id('a'))") + rep(STR("[1]"), limit)).c_str());