Use URI.escape instead of writing own code

Newlines aren't the only thing that should be escaped in links.
Instead of using custom string replacement, just use the URI library.