Encode illegal characters in query as well as path.

So we:
1. Change url-encode-path to url-encode-illegal-characters
2. Encode space to %20 to avoid clashes with + character
3. Disallow encoding of ? (legal in query and nonexistent in path)

Tests updated to reflect these changes.