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
This commit is contained in:
Tomasz Gajewski 2015-04-19 23:09:28 +02:00 committed by Norman Feske
parent 4a0b63431f
commit 611a73be36
1 changed files with 10 additions and 3 deletions

View File

@ -539,7 +539,7 @@ class Genode::Xml_node
/** /**
* Find next non-whitespace and non-comment token * 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) { while (true) {
@ -552,6 +552,13 @@ class Genode::Xml_node
continue; 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; break;
} }
return t; return t;
@ -584,7 +591,7 @@ class Genode::Xml_node
_addr(addr), _addr(addr),
_max_len(max_len), _max_len(max_len),
_num_sub_nodes(0), _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()) _end_tag(_init_end_tag())
{ {
/* check validity of XML node */ /* check validity of XML node */
@ -719,7 +726,7 @@ class Genode::Xml_node
Xml_node next() const Xml_node next() const
{ {
Token after_node = _end_tag.next_token(); 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()); } try { return _sub_node(after_node.start()); }
catch (Invalid_syntax) { throw Nonexistent_sub_node(); } catch (Invalid_syntax) { throw Nonexistent_sub_node(); }
} }