mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:23:23 +00:00
parse-xml: allow XML nodes with empty tag names
They happen for CDATA content, where libxml2 turns the CDATA fields into a child of the parent entry, but without a name. Now, of course, any sane person would just want to use the CDATA as the string value of the parent itself, but libxml2 probably does this insanity for a reason. And the reason is probably that some misguided people want to *write* XML using libxml2, and then the stupid child node actually acts as a "now I want you to write this data as CDATA". Whatever the reason, let's just ignore it. We will just traverse such a nameless child and be happy, and we'll give the nameless child the name of the parent. Our XML node matching logic will then never see this insane nameless child at all, and doesn't have to care. Our whole XML parsing rule-of-thumb is to take the whole "be strict in what you output, but generous in what you accept" to its logical conclusion. Because we will literally accept almost anything, in any format. You can mix tags or attributes wildly, and youc an use CDATA or not as you see fit. We just don't care. We're the honeybadger of the divelog world. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a1dfae87ae
commit
7aff4d70a6
1 changed files with 6 additions and 1 deletions
|
@ -1350,7 +1350,7 @@ static void visit_one_node(xmlNode *node)
|
|||
return;
|
||||
|
||||
/* Don't print out the node name if it is "text" */
|
||||
if (!strcmp(node->name, "text"))
|
||||
while (!node->name || !strcmp(node->name, "text"))
|
||||
node = node->parent;
|
||||
|
||||
name = nodename(node, buffer, sizeof(buffer));
|
||||
|
@ -1438,6 +1438,11 @@ static void traverse(xmlNode *root)
|
|||
for (n = root; n; n = n->next) {
|
||||
struct nesting *rule = nesting;
|
||||
|
||||
if (!n->name) {
|
||||
visit(n);
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
if (!strcmp(rule->name, n->name))
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue