Fix handling of incorrectly encoded uris