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

XMLISVALID builtin types check only the lexical form: out-of-range values accepted, valid special values rejected

    XMLWordPrintable

Details

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

    Description

      Values outside a type's range are accepted: integer types have no bounds check, and dates and times are not checked against the calendar. Valid special values (INF, NaN, boolean 1/0, --12) are rejected. Items in xs:list and members of xs:union are not checked at all. MDEV-41821 listed the calendar date, list and union cases; its fix left them out.

      --echo # BUG if 1
      SELECT XMLISVALID('<a>128</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:byte"/></xs:schema>') `128`;
      SELECT XMLISVALID('<a>2147483648</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:int"/></xs:schema>') `2147483648`;
      SELECT XMLISVALID('<a>9223372036854775808</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:long"/></xs:schema>') `9223372036854775808`;
      SELECT XMLISVALID('<a>0</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:positiveInteger"/></xs:schema>') `0`;
      SELECT XMLISVALID('<a>.</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:decimal"/></xs:schema>') `.`;
      SELECT XMLISVALID('<a>2023-02-29</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:date"/></xs:schema>') `2023-02-29`, XMLISVALID('<a>2024-13-01</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:date"/></xs:schema>') `2024-13-01`, XMLISVALID('<a>2024-01-01+15:00</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:date"/></xs:schema>') `2024-01-01+15:00`;
      SELECT XMLISVALID('<a>23:59:60</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:time"/></xs:schema>') `23:59:60`;
      SELECT XMLISVALID('<a>2024-01-01T25:00:00</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:dateTime"/></xs:schema>') `2024-01-01T25:00:00`;
      --echo # BUG if 0
      SELECT XMLISVALID('<a>INF</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:double"/></xs:schema>') `INF`, XMLISVALID('<a>NaN</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:double"/></xs:schema>') `NaN`;
      SELECT XMLISVALID('<a>1</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:boolean"/></xs:schema>') `1`, XMLISVALID('<a>0</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:boolean"/></xs:schema>') `0`;
      SELECT XMLISVALID('<a>--12</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" type="xs:gMonth"/></xs:schema>') `--12`;
      --echo # BUG if 1
      SELECT XMLISVALID('<a>1 x</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:simpleType name="li"><xs:list itemType="xs:int"/></xs:simpleType><xs:element name="a" type="li"/></xs:schema>') list_item, XMLISVALID('<a>zz</a>', '<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:simpleType name="un"><xs:union memberTypes="xs:int xs:boolean"/></xs:simpleType><xs:element name="a" type="un"/></xs:schema>') union_member;

      Actual: every BUG if 1 result is 1. In the BUG if 0 block, everything is 0 except boolean 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.