Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I feel like we ought to be doing this in a way where the output is
> properly escaped.
This is one of several reasons why code shouldn't be trying to scrape
the names out of the human-readable message.
regards, tom lane