jazzband / jsonmodels

jsonmodels is library to make it easier for you to deal with structures that are converted to, or read from JSON.
http://jsonmodels.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
334 stars 51 forks source link

Regex validator: All flags are ignored if ECMA regex is provided #104

Closed avrahamshukron closed 6 years ago

avrahamshukron commented 6 years ago

Simply put:

In [13]: v = Regex("foobar", multiline=True)
In [14]: v.flags
Out[14]: [8]  # As expected

In [16]: v = Regex("/foobar/i")
In [17]: v.flags
Out[17]: []  # WTF?

In [18]: v = Regex("/foobar/i", multiline=True)
In [19]: v.flags
Out[19]: []  # WTF?!?!

It appears that providing an ECMA regex will actually cause the library to ignore any flags provided in any way.

This is clearly a bug, and in direct contradiction to the documentation which state that:

Note, that if given pattern is ECMA regex, given flags will be completely ignored and taken from given regex.

beregond commented 6 years ago

That one was merged, thanks!