Comply to RFC 3986. Fixes #1630.