[SPARK-2718] [yarn] Handle quotes and other characters in user args.

Due to the way Yarn runs things through bash, normal quoting doesn't
work as expected. This change applies the necessary voodoo to the user
args to avoid issues with bash and special characters.

The change also uncovered an issue with the event logger app name
sanitizing code; it wasn't cleaning up all "bad" characters, so
sometimes it would fail to create the log dirs. I just added some
more bad character replacements.
Yeah, this is the tricky one. Escaping single quotes inside a single-quoted string does not work.

So what you have to do is close the previous string (remember the whole thing is wrapped in single quotes), and start a new string, delimited by double quotes, with a single single quote in it. So basically, for a string containing a single single quote, you're concatenating three different strings:

- An empty string at the start: ''
- The single quote, wrapped in double quotes: "'"
- An empty string at the end: ''

And since all this is already inside double quotes in the bash script itself, you need to also escape the double quotes. Fun.