security patches

Did things more the rails way to prevent sql injection.

Added proper anchors to my regex.