Open commonism opened 1 month ago
Thanks for catching these! I'll raise them to the rest of the group
At least other regex tools seem to allow for this... I'll need to see if I can get something up myself in Rust to check things out...
Looking into this a bit, and I suspect escaping the [ is not correct; I think the intended regex is:
(^Passphrase: [^ !#\-~]+$)
Update: Disregard; I'm working with someone on what the format really needs to be.
As #-~
is a range
''.join(chr(i) for i in range(ord("#"),ord("~")+1))
"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
which already includes [ and ^ - …, we'll see where this ends up.
You can make use of rust regex via
from pydantic import BaseModel, Field
class B(BaseModel):
# model_config = dict(regex_engine="python-re")
v: str = Field(pattern=r"(^[ !#-~]+$)|(^Passphrase:[ ^[ !#-~]+$)|(^Hex:[0-9A-Fa-f]{24,96})|(^\*+$)")
It'll bail out.
The regex
are considered invalid by rust regex.
It's accepted by python re.
Yet I think it lacks an escape for the
[
in^[