Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355343

XSD Regex Validation Allows Mistaken Single Character Escapes

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The XSD spec has a specific list of what can be escaped with `\`. This can be found here: https://www.w3.org/TR/xmlschema-2/#nt-SingleCharEsc. This list does not include `$` or `/`, however the standard Validator allows `\/` and `\$`. Xmllint correctly throws an error when it encounters this in an XSD pattern.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an XSD schema (defined by "http://www.w3.org/2001/XMLSchema") that uses a pattern restriction on a string of "\$". The idea behind this pattern is to match a single `$` character. The correct way to implement this in XSD is "[$]".

      Then load this schema using `SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(resource);`

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The expected result is that the schema fails to parse and an error is thrown.
      ACTUAL -
      The actual result is that the schema loads just fine and is able to validate.

            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: