This fixes path traversal and command injection in Custom Commands file editors.
It replaces shell-based path expansion with confined Perl expansion and validates non-path parameters.
It also applies ownership and permissions without invoking a shell.