graphite escape fixes for 5.4

This was reported by @tas50 in https://github.com/collectd/collectd/pull/611 a few months ago but the back/forward port to 5.4 might have slipped through the cracks.