sdmx3mdt / public-consultation

0 stars 0 forks source link

Review RegEx expressions (use ^ to limit the string start and $ to limit the string end) #21

Closed dosse closed 3 years ago

dosse commented 3 years ago

It seems that the regex expressions need to encapsulated within '^' and '$' characters. This is necessary to disallow any unwanted characters at the beginning of the string and at the end of the string.

E.g. the current LegacyVersionNumberType regex (0|[1-9]\d*)(\.(0|[1-9]\d*))? allows not only for version numbers 1 or 1.0 but also for AnyString1.0, 1.0AnyString and AnyString1.0AnyString. Tests can be made e.g. here: https://regexr.com/

The required regular expression would be ^(0|[1-9]\d*)(\.(0|[1-9]\d*))?$. I believe that this also holds for regular expressions defined in XML.

sdmx3mdt commented 3 years ago

No change required. J Gager reports that terminating '^' and '$' are implied in XML schema regex. An article on the topic can be found here.

dosse commented 3 years ago

@sdmx3mdt Ok, thanks.