majewsky / portunus

Self-contained user/group management and authentication service
GNU General Public License v3.0
75 stars 5 forks source link

Avoid pitfall when appending example group #32

Open SuperSandro2000 opened 2 months ago

SuperSandro2000 commented 2 months ago
majewsky commented 2 months ago

must be escaped when not last

That's true, but I don't see in the upstream documentation that using a backslash for escaping is allowed here. Backslash in front of a regular character only has meaning for atoms according to that spec, not for character class elements.

SuperSandro2000 commented 2 months ago

true but they show it in their examples under ASCII character classes for [[:graph:]] https://pkg.go.dev/regexp/syntax#:~:text=%5B%5B%3Agraph%3A%5D%5D%20graphical%20(%3D%3D%20%5B!-~%5D%20%3D%3D%20%5Ba-za-z0-9!%22%23%24%25%26'()*%2B%2C%5C-.%2F%3A%3B%3C%3D%3E%3F%40%5B%5C%5C%5C%5D%5E_%60%7B%7C%7D~%5D) 😅

When appending something to the regex like \. it needs to be escaped, otherwise the character class is invalid

^[a-z_][a-z0-9_\-\.]*\$?$

tested this while trying to unwedge our mail setup.