Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

Validate "pattern" with re.search() instead of re.match() #241

Closed keriehm closed 9 months ago

keriehm commented 3 years ago

The re.match() method only looks for the regex at the beginning of the input, but the JSON Schema rules for "pattern" (as referenced by the Swagger/OpenAPI spec), state that "regular expressions are not implicitly anchored".

The result of using re.match() is that some valid values are rejected during client-side validation, if the pattern was written to match against something other than the start of the string. Using re.search() removes this implicit front-anchoring, so these values are not rejected.

A link for reference: http://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.6.3.3

lmazuel commented 9 months ago

This package is now deprecated and no longer receives update. Recent SDK stopped doing client side validation and pattern verification, meaning this is no longer a problem.