url-escape the 'target' parameter to avoid 'URI::InvalidURIError: bad URI(is not URI?)'.
Don't require superfluous uri library.
Merge pull request #538 from bma/master

url-escape the 'target' parameter