ast_safe_system in returning -1

FreePBX uses to execute a script converting the TIF files from a fax receipt to a PDF and emailing it to the user. In the command always fails. It appears that ast_safe_system is returning a -1 and it isn’t clear on the reason. I’ve copied the command in the log and pasted it to the asterisk command line prefixed by a ! and it ran without issue. I’ve removed the email address and phone numbers to protect the innocent! Any suggestions?

The log reports:
[Feb 12 12:51:06] VERBOSE[7926] pbx.c: – Executing [h@ext-fax:2] ^[[1;36mExecIf^[[0m("^[[1;35mSIP/DefaultOut-00000002^[[0m", “^[[1;35m1?system(’/var/lib/asterisk/bin/ --to email-removed --from “email-removed” --dest “num-removed*” --subject “New fax from num-removed” --attachment fax_num-removed.pdf --type application/pdf --file /var/spool/asterisk/fax/1266004233.2.tif’)^[[0m”) in new stack

WARNING[7926] app_system.c: Unable to execute ‘’/var/lib/asterisk/bin/ --to email-removed --from email-removed --dest num-removed --subject New fax from num-removed --attachment fax_num-removed.pdf --type application/pdf --file /var/spool/asterisk/fax/1266004233.2.tif’’

I think this is related to the system() function in the dialplan no longer accepting arguments that are single quoted. Seems like a bug but will make the changes accordingly to the generated dialplan.

Maybe related to the following line added in app_system.c?

ast_str_get_encoded_str(&buf, 0, (char *) data);

Anyway, workaround is to make sure there are no quotes in the passed argument.