Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
69 stars 50 forks source link

`[cbuild schema]` Use of unsupported regex characters in `pattern` #1561

Open acabarbaye opened 3 weeks ago

acabarbaye commented 3 weeks ago

Describe the bug In schema 2.4 of cbuild-idx, a regex specifying build context names was introduced https://github.com/Open-CMSIS-Pack/devtools/blob/17b2ab16730cd6c5305d8714b1976b6185e9dab4/tools/projmgr/schemas/common.schema.json#L16 Similar pattern definitions using regexes were also added to other fields.

The use of pattern helps significantly the validation of file entries. However, json format is quite limited in what is supported when it comes to regexes https://json-schema.org/understanding-json-schema/reference/regular_expressions and does not support notations such as \w or \W. Therefore, could the shortcut notations be replaced by their extended definitions: e.g. \w changed to [^A-Za-z0-9_] so that any json schema tools can be used effectively?

Moreover, special characters such as . or + should be escaped if the characters themselves should be considered and not the corresponding regex semantic.

The following regex "^[^.+]*(\\.[\\w-]{1,32}|\\+[\\w-]{1,32}|\\.[\\w-]{1,32}\\+[\\w-]{1,32})$" should hence be replaced by "^([^\\.\\+]+|[^\\.\\+]*\\.[a-zA-Z0-9_-]{1,32}(\\+[a-zA-Z0-9_-]{1,32})|[^\\.\\+]*\\+[a-zA-Z0-9_-]{1,32}(\\.[a-zA-Z0-9_-]{1,32})?)$" to abide by the json schema specification.

Environment (please complete the following information):

schema 2.4