From 6144280fdeef335cffefe529ba09583552da9b4b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 27 Feb 2012 07:02:11 +0000 Subject: [PATCH] fix xml parser issue and the xml unit test --- include/libtorrent/xml_parse.hpp | 3 +++ test/test_primitives.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/xml_parse.hpp b/include/libtorrent/xml_parse.hpp index 9f075f5c2..604b73287 100644 --- a/include/libtorrent/xml_parse.hpp +++ b/include/libtorrent/xml_parse.hpp @@ -192,9 +192,12 @@ namespace libtorrent // instead of a series of key value pairs if (i == tag_end) { + char tmp = *i; + *i = 0; // null terminate the content string token = xml_tag_content; val_start = 0; callback(token, start, val_start); + *i = tmp; break; } diff --git a/test/test_primitives.cpp b/test/test_primitives.cpp index 1e553e738..e045f97b7 100644 --- a/test/test_primitives.cpp +++ b/test/test_primitives.cpp @@ -119,6 +119,7 @@ void parser_callback(std::string& out, int token, char const* s, char const* val case xml_string: out += "S"; break; case xml_attribute: out += "A"; break; case xml_parse_error: out += "P"; break; + case xml_tag_content: out += "T"; break; default: TEST_CHECK(false); } out += s; @@ -1345,7 +1346,7 @@ int test_main() xml_parse(xml4, xml4 + sizeof(xml4) - 1, boost::bind(&parser_callback , boost::ref(out4), _1, _2, _3)); std::cerr << out4 << std::endl; - TEST_CHECK(out4 == "BaPgarbage inside element bracketsSfooFaPgarbage inside element brackets"); + TEST_CHECK(out4 == "BaTfSfooFaTv "); // test upnp xml parser