Use CGI.escape instead of URI.escape