Fixes #6560 - Extract puppet parsing logic

We're using to_sym on an untrusted input here (it comes from the facts hash directly) which is unsafe. Perhaps we should use string lookups instead?