Handle Malformed URIs Bug

Fixes #978