Use URI.encode instead of CGI::escape to compose URIs and username validation

Closes #134