pandorafms/pandorafms — pull request #4 by uchida (2014-11-19 07:53:50+00:00)
Title: Escape quotes in alert command args

This pull request fix the problems that the alert command such as `/path/to/alert-command.sh '_data_'` fails execution when macros, for example `_data_` in logging alert, include quotes.

An approach of this pull request is the following:

1. Divide an alert command into arguments based on whitespace and quotes.
2. Substitute alert macros for each arguments.
3. Escape quotes in each arguments of alert command if the argument is a single/double-quoted string, such as `'single quoted'` `"double quoted"`.
* `"` will be replaced with `\"` and don't escape twice: `\"` won't be replaced with `\\"`
* `'` will be replaced with `'\''`, close quote, escape quote and open quote
4. Reconstruct an alert command from arguments and execute it.