Add invalid character replacement

This fixes the bug seen here:
http://pastebin.com/QzWQQndK

Which would generate an Argument Error causing "vagrant up" and other such commands to fail.
Merge pull request #2514 from AJCStriker/patch-1

core: add invalid character replacement in Which util