Fix invalid URI handling.