Sanitize query strings

This pull request addresses potential XSS exploit due to incorrect handling of user inputs used on query strings.