fix malformed destination query string after substitution