toContain('cacti_escapeshellarg(htmle($value))'); }); test('the resolved right-axis-label value is escaped', function () use ($rrd) { expect($rrd)->toContain("--right-axis-label ' . cacti_escapeshellarg(\$value)"); }); test('the post-escape whole-command substitution is removed', function () use ($rrd) { expect($rrd)->not->toContain('$graph_opts = rrd_substitute_host_query_data($graph_opts, $graph, []);'); }); test('cacti_escapeshellarg neutralises a device-supplied quote', function () { require_once dirname(__DIR__, 4) . '/lib/functions.php'; $GLOBALS['config']['cacti_server_os'] = 'unix'; $wrapped = cacti_escapeshellarg("Traffic eth0' COMMENT:pwned"); expect($wrapped)->not->toContain("Traffic eth0' COMMENT"); expect(substr($wrapped, 0, 1))->toBe("'"); });