[module] sanity (user input)

Hi all,

So, in working on a Yii app, I came across the fact that Yii doesn’t have any native input sanitization features. Not a bit deal as most of them are simply filters, but would be nice to have a module for this to just slap into projects on an as-needed basis (obviously with an extended feature set).

Enter sanity -

My first crack at a module, so I’m looking for feedback and suggestions on everything from the project’s directory structure to features that people would like to see implemented. The current feature set is mostly wrappers for native PHP filter functions, but does have a few regex constants that I found were useful when using Yii’s match validator, as well as a function to parse specified input code tags (such as [b] and [i]) and return proper HTML.

https://github.com/demianbrecht/sanity

Any feedback and/or comments are much appreciated.

I hope i don’t diminish your achievments much, but

  1. Why use a module? A module represents a complete sub-application. You’d maybe rather want to create a validator.

  2. Did you check CFilterValidator?

Nope, you didn’t diminish the achievements at all, as I’m very well aware that the achievement is VERY minimal :)

There were two reasons that I stuck this in a module:

  1. Modularity - something that I can just simply copy and paste (or link) into any number of projects from a root directory without having to search for files distributed throughout. As it stands, most of the functionality (other than the parsing function) could most likely be captured by functionality already exposed by Yii (I didn’t look into CFilterValidator much (I’m still fairly new to Yii), I’ll do so), but putting the core functionality into a module made sense in terms of extensibility. If I want to create a masked input text widget or anything along those lines or a preview widget that takes the input that the parser function takes as input and displays the output to the user client-side, I now have a central location to do so.

  2. Learning - really, this was done more to figure things out than anything else, in and outside of Yii… Working with Github, creating a directory structure that would work nicely with Yii modules and unit testing based off of the Yii bootstrapper.

I fully realize that the usefulness of the module isn’t really high as it stands, but I’m pretty sure that will increase as I dig more into a number of different types of applications.