[x3d-public] X3D regular expression (regex) improvements

Andreas Plesch andreasplesch at gmail.com
Fri Aug 17 20:06:31 PDT 2018


What about expanding the validation to multiple regexes which all need to
match to check for illegal values where necessary ?

first: !((0|0.0*|.0+)\s+){3})*

second: actual SFRotation pattern

Can there be multiple regexes in the XML Schema for a type ?


SFImage regex considerations:

Are hex values allowed for width etc. ? The spec. only says integer but
perhaps decimal is implied.

Can hex. values use any case for letters ? The descriptions only use
capitals as 0xFF. Is 0Xff also valid ?

0 0 0 is the default value. But should 0 be allowed for components in any
other case ?

No leading 0s for integer values.

But 0x0000FF is OK.

No negative integers for width etc.

Perhaps allow negative values for color: 255 = -1 for single component, for
example.



-- AP on the road


On Fri, Aug 17, 2018, 3:15 PM Don Brutzman <brutzman at nps.edu> wrote:

> details follow on current regex progress.
>
> On 8/7/2018 8:21 AM, Don Brutzman wrote:
> > [...]
> > http://www.web3d.org/specifications/X3dRegularExpressions.html#Design
> > http://www.web3d.org/specifications/X3dRegularExpressions.png
> >
> > Continuing:
> >
> > On 8/6/2018 11:52 AM, Andreas Plesch wrote:
> >> Two quick points:
> >>
> >> The hexadecimal pattern got corrupted. SFImage uses this pattern:
> >>
> >> 0x([a-f]|[A-F]|\d]){1,8}
> >>
> >> where \d is the digit character class.
> >
> > Thanks, will work on that pattern next.
>
> Currently using 0x[0-9a-fA-F]{1,8} for hexadecimal value, from Regular
> Expressions Cookbook.
>
> Preliminary pattern for SFImage is there, but also need to allow integers
> as alternatives for hex values.
>
> >> There are two equivalent +- patterns
> >> (\+|\-)?
> >> [+|-]?
> >> Probably only one should be recommended and used subsequently.
> >
> > Good catch, thank you.  Will scrutinize and normalize.
>
> [+-]? for sign and [Ee] for scientific-notation exponent.
>
> >> I have no good idea how to detect a leading 0 0 0 as non-matching. My
> >> not so good idea would be to explicitly allow
> >> non-0 followed by x x or
> >> x followed by non-0 followed by x or
> >> x x followed by non-0
> >>
> >> where non-0 is something [+-]?0?\.?[0-9]*[1-9]+[0-9]*([e|E][+-]?[0-9]+)*
> >> and x is a floating point number
> >>
> >> -Andreas
> >
> > Possibly, but am thinking it adds serious complexity that is hard to
> maintain.  So probably not but will think about it.
>
> It is great when we find those patterns, am trying to keep things
> maintainable.  The color-coding on web page definitely helps.
>
> Negative lookahead is good for avoiding illegal values, but not allowed in
> XML Schema (probably to avoid computational denial of service attacks_.
> Have listed a pattern nevertheless, other languages/tools might want to use
> it.
>
> ==================
> Disallowed values:
>
> * Negative lookahead filters can disqualify attributes that contain
> illegal values.
> * W3C Recommendation for XML Schema (XSD) unfortunately does not support
> this construct.
> * (?!((0|0.0*|.0+)\s+){3}) prohibits 0 0 0 since zero vector is illegal as
> initial axis triplet of an SFRotation.
> * (?!\s*,\s*,) prohibits multiple adjacent commas in intermediate
> whitespace, for example 0 0 0, ,0 0 0 is an illegal set of MFColor values.
> ==================
>
> > Thanks for the continuing review!  Very helpful.
> Steadily better and better... need to check each regex101 unit test to
> make sure properly updated.  SF/MFImage are next, then matrix types.
>
> all the best, Don
> --
> Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/
> <http://faculty.nps.edu/brutzman>brutzman
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180817/a7c9aac8/attachment-0001.html>


More information about the x3d-public mailing list