From 611a73be36679b0924c25b3346aaa205f8c9d2dc Mon Sep 17 00:00:00 2001 From: Tomasz Gajewski Date: Sun, 19 Apr 2015 23:09:28 +0200 Subject: [PATCH] Fixed inconsistency in XML parser Changed Xml_node::next() to treat text between nodes in the same manner like Xml_node::_init_end_tag which counts number of subnodes. Issue #1424 --- repos/os/include/util/xml_node.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/repos/os/include/util/xml_node.h b/repos/os/include/util/xml_node.h index fc60c1b92..a5e86a98d 100644 --- a/repos/os/include/util/xml_node.h +++ b/repos/os/include/util/xml_node.h @@ -539,7 +539,7 @@ class Genode::Xml_node /** * Find next non-whitespace and non-comment token */ - static Token eat_whitespaces_and_comments(Token t) + static Token skip_non_tag_characters(Token t) { while (true) { @@ -552,6 +552,13 @@ class Genode::Xml_node continue; } + /* skip token if it is valid but does not start a tag */ + Tag curr_tag(t); + if (curr_tag.type() == Tag::INVALID && curr_tag.token()) { + t = t.next(); + continue; + } + break; } return t; @@ -584,7 +591,7 @@ class Genode::Xml_node _addr(addr), _max_len(max_len), _num_sub_nodes(0), - _start_tag(eat_whitespaces_and_comments(Token(addr, max_len))), + _start_tag(skip_non_tag_characters(Token(addr, max_len))), _end_tag(_init_end_tag()) { /* check validity of XML node */ @@ -719,7 +726,7 @@ class Genode::Xml_node Xml_node next() const { Token after_node = _end_tag.next_token(); - after_node = eat_whitespaces_and_comments(after_node); + after_node = skip_non_tag_characters(after_node); try { return _sub_node(after_node.start()); } catch (Invalid_syntax) { throw Nonexistent_sub_node(); } }