Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-42392

XMLISVALID: attribute on xs:anyType element ends validation of that element, invalid XML accepted

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • N/A
    • 13.3
    • XML Functions
    • None

    Description

      XMLSchema_any_type::validate_attr() accepts the attribute but pushes nothing on the validation stack, so the end of the attribute pops the element itself (XMLSchema_element_global::validate_leave()). The rest of the element, its closing tag included, is then validated one level up: children are matched against the parent's content model or the global elements, and the parent's end check runs at the element's closing tag. Elements without a type are xs:anyType since MDEV-41821, so they are affected as well.

      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="r"/></xs:schema>';
      --echo # BUG if with_attr = 0, r has no type (xs:anyType)
      SELECT XMLISVALID('<r><x/></r>', @s) AS no_attr, XMLISVALID('<r a="1"><x/></r>', @s) AS with_attr;
       
      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="R"><xs:complexType><xs:sequence>
        <xs:element name="E" type="xs:anyType"/>
        <xs:element name="F" type="xs:int" minOccurs="0"/>
      </xs:sequence></xs:complexType></xs:element>
      <xs:element name="F" type="xs:string"/>
      </xs:schema>';
      --echo # BUG if with_attr = 1, local F is xs:int
      SELECT XMLISVALID('<R><E></E><F>abc</F></R>', @s) AS no_attr, XMLISVALID('<R><E a="1"></E><F>abc</F></R>', @s) AS with_attr;

      13.2.0-MariaDB-asan-debug-log source revision: bd45fd917d4ef23ca1c4f62ca63473c08c03c8de
       
      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="r"/></xs:schema>';
      # BUG if with_attr = 0, r has no type (xs:anyType)
      SELECT XMLISVALID('<r><x/></r>', @s) AS no_attr, XMLISVALID('<r a="1"><x/></r>', @s) AS with_attr;
      no_attr	with_attr
      1	0
      SET @s= '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="R"><xs:complexType><xs:sequence>
        <xs:element name="E" type="xs:anyType"/>
        <xs:element name="F" type="xs:int" minOccurs="0"/>
      </xs:sequence></xs:complexType></xs:element>
      <xs:element name="F" type="xs:string"/>
      </xs:schema>';
      # BUG if with_attr = 1, local F is xs:int
      SELECT XMLISVALID('<R><E></E><F>abc</F></R>', @s) AS no_attr, XMLISVALID('<R><E a="1"></E><F>abc</F></R>', @s) AS with_attr;
      no_attr	with_attr
      0	1

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.