Regexps considered harmful; documentation is sloppy about regexps #6

Open
tv42 opened this Issue Feb 28, 2011 · 1 comment

Projects

None yet

2 participants

@tv42
tv42 commented Feb 28, 2011

I hope you'll reconsider using regexps for matching identifiers on the command line. It makes it too easy for admins to shoot themselves in the foot. To prove my point, the docs at http://melor.github.com/poni/template-variables.html use an unanchored $find("webshop/frontend"), which would match e.g. webshop/frontendforsomethingelse.

I'd be much happier if Poni used globs, because they have way fewer magic characters, and those tend to stick out more. I've seen people hurt themselves even with the periods in DNS domain names, when used directly as a regexp pattern. You could always provide a --regex option for when the power is needed.

@melor
Member
melor commented Mar 2, 2011

There are a two separate variables here: full string matching vs. partial string matching and the pattern matching syntax used (regex vs. glob).

I believe you are right with your concerns and I have actually been already thinking about changing the default to be strict full path matching for most commands and template functions. Using globs did not occur to me as I was only aware of the "glob" module, which does not provide generic pattern matching functionality, just globbing file paths. Now that I dug a bit deeper and found "fnmatch", I see that using it would be rather trivial for this purpose.

However, there are already multiple souls whose wrath will unleash over me if I change the default behavior, so making this change happen will need some careful coordination.

Issue in consideration, no ETA yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment