Fix argument parsing for arguments containing pound signs

Passing these through yaml.safe_load() will result in the pound sign and
everything after it being interpreted as a comment. This commit stops
the argument from being passed through yaml.safe_load if it is a string
and contains a pound sign.

Fixes #8585.