added validation and sanitizing functions for mitigating RCE vulnerabilities

part of fix for https://github.com/opentechinstitute/luci-commotion-apps/issues/10, https://github.com/opentechinstitute/luci-commotion-apps/issues/11, https://github.com/opentechinstitute/luci-commotion-apps/issues/13