Page MenuHomePhabricator

Check regular expression validity in wbcheckconstraintparameters
Open, Needs TriagePublic

Description

The “format as a regular expression” parameter of “format” constraints currently can’t be validated very well: if the regex is invalid, that’s a “bad parameter” status, which we hide in the gadget by default, under the rationale that we flag bad parameters on the property page instead; however, the wbcheckconstraintparameters API action we use for that doesn’t validate regular expressions, so on the property page you don’t see the error at all.

I figure we need to bite the bullet and do a SPARQL request on wbcheckconstraintparameters calls so that we can report invalid regexes. We can at least cache the information whether a regular expression is valid. (Perhaps independent of our normal regex cache – there are way less regexes than regex-value combinations, so for this we shouldn’t need to bother with cache maps.)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 4 2018, 11:18 AM

We can at least cache the information whether a regular expression is valid. (Perhaps independent of our normal regex cache – there are way less regexes than regex-value combinations, so for this we shouldn’t need to bother with cache maps.)

Or, alternatively – if the regex is invalid, it’s invalid for any value. So if there is any cache map in the cache, regardless of which values it contains, we can just look at any one of the values and check if it’s true or false (regex okay) or a serialized ConstraintParameterException (deserialize and return).