-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib.yang: support for pattern restrictions #1263
Conversation
…..]" This reverts commit 958c37d.
General categories are only implemented for the ASCII range, the predicates return false for all codepoints outside of ASCII. For lib.xsd_regexp that means it can’t match category escapes on non-ASCII input, i.e. it can’t fully handle Unicode input. It can however apply all valid regular expressions to ASCII input. Caveat: users of category escapes must restrict their input to ASCII. In order to fix this, we would need (access to) a full Unicode database in which we could look up codepoints and their attributes.
This reverts commit 76acfd3.
This reverts commit ea0978a.
…I-only This reverts commit c3ef659.
lib.maxpc: add backtracking combinators
Right, this can’t work right now since IP addresses are converted to numbers before the validators see them… I didn’t notice this before because I have disabled that behavior on my downstream branch, my bad! I guess I can guard the pattern validator on the invariant that the value to be validated is a string. |
This extra guard is necessary because some intrinsic lib.yang extensions will parse/validate some types natively (e.g. IP addresses using lib.protocol.ipvX) circumventing the YANG validation stack.
That being fixed, the next error appears to be a lwaftr test assuming ranges are single intervals: https://gist.github.com/SnabbBot/47076ad6d12879c3ce4d9ba4bf8ccbd7#file-log-L816 Edit: Actually they just use a different format. |
When hacking the range validator I had misunderstood the format used to express YANG range restrictions (I thought it didn’t feature multiple intervals), and changed it along the way. I think the new format is a bit simpler though (more regular) and requires less special cases, so I decided to keep it.
8b27755
to
e577721
Compare
All good to go! |
Given that wingo-next has a lot of changes to some of the same stuff and that it's ready to go modulo some unrelated perf regression, I propose holding off here; unless you want to change the base branch to wingo-next of course. WDYT? |
I am in no particular rush to get this merged, so I guess feel free to pick it up whenever convenient. |
5579f1e
to
4396c52
Compare
4396c52
to
03daccb
Compare
Merged the current master. Note that besides the pattern validator this PR also...
|
Actually, I found a glaring omission in the Regex implementation (duh) over the weekend, so please put merging this on hold until I come up with a fix. :-)
|
Removes the broken match.range and replaces match.all with a simple implementation by means of match.plus. In lib.xsd_regexp implement backtracking match.range combinator by means of match.all. Simplify variable argument variants of match.plus and match.alternate along the way.
Ok should be better now! :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jessica kindly had a thorough look and says LGTM, so I say LGTM as well :) Looks really cool!
Adds support for pattern and to lib.yang. The XSD Regex implementation is of questionable design (at least it was fun to hack), and has some restrictions:
Generally speaking, its not advisable to use it for sanitizing non-ASCII input. It’s good enough to parse things like the IP address patterns we use though.
I could add full unicode support (I have a branch that interprets the strings as UTF-8), it’s just that I have decided not to, because I wasn’t sure if sticking a whole Unicode databse into the
snabb
binary was worth it. If anyone actually needs Unicode support in Yang patterns, I will happily add it back in!Cc @wingo