Fix issue with malformed query strings resulting in an exception