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
devel
Tomasz Gajewski 8 years ago committed by Norman Feske
parent 4a0b63431f
commit 611a73be36
  1. 13
      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(); }
}

Loading…
Cancel
Save