Local file storage fixes

Patch

 * Validate the subdomain/filename that gets written on disk
 * Make subdomains case insensitive
 * Syntax error fix