URL encoding and decoding

Use encodeURIComponent instead of encodeHTML — encodeHTML is not appropriate here.