genode/repos/base/recipes/pkg/test-xml_node/runtime
Norman Feske c2efa5406e xml_node: support backslash as attribute value
XML allows attribute values like <node attr="\"/>. The XML parser
wrongly reflects this case as 'Invalid_syntax'. This behavior stems from
the implicit use of the 'end_of_quote' function, which considers the
sequence of '\"' as a quoted '"' rather than the end of a quoted string.

The patch solves this problem by making the 'end_of_quote' part of
the tokenizer's scanner policy.

The patch removes the 'end_of_quote' function from 'util/string.h'
because it is not universal, and to avoid the ambiguity with
'SCANNER_POLICY::end_of_quote'.

Fixes #4431
2022-02-21 15:44:22 +01:00

138 lines
7.4 KiB
Plaintext

<runtime ram="32M" caps="1000" binary="init">
<events>
<timeout meaning="failed" sec="20" />
<log meaning="succeeded">
[init -> test-xml_node] --- XML-token test ---
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="&lt;"
[init -> test-xml_node] token type="IDENT", len=6, content="config"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content=">"
[init -> test-xml_node] token type="WHITESPACE", len=2, content=" "
[init -> test-xml_node] token type="IDENT", len=9, content="sometext1"
[init -> test-xml_node] token type="WHITESPACE", len=2, content=" "
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="&lt;"
[init -> test-xml_node] token type="IDENT", len=7, content="program"
[init -> test-xml_node] token type="WHITESPACE", len=1, content=" "
[init -> test-xml_node] token type="IDENT", len=4, content="attr"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="="
[init -> test-xml_node] token type="STRING", len=6, content=""abcd""
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="/"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content=">"
[init -> test-xml_node] token type="WHITESPACE", len=2, content=" "
[init -> test-xml_node] token type="IDENT", len=9, content="sometext2"
[init -> test-xml_node] token type="WHITESPACE", len=2, content=" "
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="&lt;"
[init -> test-xml_node] token type="IDENT", len=7, content="program"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content=">"
[init -> test-xml_node] token type="IDENT", len=9, content="inProgram"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="&lt;"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="/"
[init -> test-xml_node] token type="IDENT", len=7, content="program"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content=">"
[init -> test-xml_node] token type="WHITESPACE", len=2, content=" "
[init -> test-xml_node] token type="IDENT", len=9, content="sometext3"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="&lt;"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content="/"
[init -> test-xml_node] token type="IDENT", len=6, content="config"
[init -> test-xml_node] token type="SINGLECHAR", len=1, content=">"
[init -> test-xml_node] --- XML-parser test ---
[init -> test-xml_node] -- Test valid XML structure --
[init -> test-xml_node] XML node: name = "config", number of subnodes = 3
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "init"
[init -> test-xml_node] XML node: name = "quota", leaf content = "16M"
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "timer"
[init -> test-xml_node] XML node: name = "quota", leaf content = "64K"
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "framebuffer"
[init -> test-xml_node] XML node: name = "quota", leaf content = "8M"
[init -> test-xml_node]
[init -> test-xml_node] -- Test invalid XML structure (broken tag) --
[init -> test-xml_node] XML node: name = "config", number of subnodes = 3
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "init"
[init -> test-xml_node] XML node: name = "quota", leaf content = "16M"
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "timer"
[init -> test-xml_node] XML node: name = "quota", leaf content = "64K"
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "framebuffer"
[init -> test-xml_node] XML node: name = "quota", leaf content = "8M"
[init -> test-xml_node]
[init -> test-xml_node] -- Test invalid XML structure (truncated) --
[init -> test-xml_node] string has invalid XML syntax
[init -> test-xml_node]
[init -> test-xml_node] -- Test invalid XML structure (truncated comment) --
[init -> test-xml_node] string has invalid XML syntax
[init -> test-xml_node]
[init -> test-xml_node] -- Test invalid XML structure (unfinished string) --
[init -> test-xml_node] string has invalid XML syntax
[init -> test-xml_node]
[init -> test-xml_node] -- Test node access by key --
[init -> test-xml_node] content of sub node "filename" = "init"
[init -> test-xml_node] content of sub node "quota" = "16M"
[init -> test-xml_node] sub node "info" is not defined
[init -> test-xml_node]
[init -> test-xml_node] -- Test access to XML attributes --
[init -> test-xml_node] XML node: name = "config", number of subnodes = 3
[init -> test-xml_node] attribute name="priolevels", value="4"
[init -> test-xml_node] XML node: name = "program", number of subnodes = 2
[init -> test-xml_node] XML node: name = "filename", leaf content = "init"
[init -> test-xml_node] XML node: name = "quota", leaf content = "16M"
[init -> test-xml_node] XML node: name = "single-tag"
[init -> test-xml_node] XML node: name = "single-tag-with-attr"
[init -> test-xml_node] attribute name="name", value="ein_name"
[init -> test-xml_node] attribute name="quantum", value="2K"
[init -> test-xml_node]
[init -> test-xml_node] -- Test parsing XML with nodes mixed with text --
[init -> test-xml_node] XML node: name = "config", number of subnodes = 2
[init -> test-xml_node] XML node: name = "program"
[init -> test-xml_node] attribute name="attr", value="abcd"
[init -> test-xml_node] XML node: name = "program", leaf content = "inProgram"
[init -> test-xml_node]
[init -> test-xml_node] -- Test parsing XML with comments --
[init -> test-xml_node] XML node: name = "config", number of subnodes = 2
[init -> test-xml_node] XML node: name = "visible-tag"
[init -> test-xml_node] XML node: name = "visible-tag"
[init -> test-xml_node]
[init -> test-xml_node] -- Test backslash as attribute value --
[init -> test-xml_node] attribute value: '\'
[init -> test-xml_node]
[init -> test-xml_node] -- Test exporting decoded content from XML node --
[init -> test-xml_node] step 1
[init -> test-xml_node] step 2
[init -> test-xml_node] step 3
[init -> test-xml_node] step 4
[init -> test-xml_node] step 5
[init -> test-xml_node]
[init -> test-xml_node] -- Test iterating over invalid node --
[init -> test-xml_node]
[init -> test-xml_node] --- End of XML-parser test ---*
[init] child "test-xml_node" exited with exit value 0
</log>
<log meaning="failed">Error: </log>
</events>
<content>
<rom label="ld.lib.so"/>
<rom label="test-xml_node"/>
</content>
<config>
<parent-provides>
<service name="LOG"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="PD"/>
</parent-provides>
<default-route>
<any-service> <parent/> </any-service>
</default-route>
<default caps="100"/>
<start name="test-xml_node">
<resource name="RAM" quantum="10M"/>
</start>
</config>
</runtime>