added input validation and sanitizing for mitigating RCE vulnerabilities

works in conjunction with https://github.com/opentechinstitute/luci-commotion/pull/29

part of fix for opentechinstitute/luci-commotion-apps#10, opentechinstitute/luci-commotion-apps#11, opentechinstitute/luci-commotion-apps#13