Single quotes have to be quoted in the protocol, but were forgotten.
This is easy enough to fix but isn't helped by the fact that there
are three different copies of this bug on the perl side, so let's
split out that function into a new module and fix it there.