Fix grants to work with wildcard hosts

The current grant code fails when using a wildcard host (`%`), because
it's not properly quoted.  Fixed the quoting and wrote a spec for it.