【发布时间】:2010-11-18 08:38:54
【问题描述】:
我在 Linux 上使用 Exiv2 命令行工具来编辑图像元数据,如下所示:
exiv2 -M"set Iptc.Application2.Caption String This is my caption....." modify IMG.jpg
我想使用用户提供的标题从 PHP 执行此操作。如果用户没有输入特殊字符,这将起作用:
exec('/usr/local/bin/exiv2 -M"set Iptc.Application2.Caption String '.$caption.'" modify IMG.jpg');
我需要允许用户使用特殊字符,例如单引号和双引号。我想使用 escapeshellcmd() 来防止恶意数据。如何正确转义命令和参数以使其正常工作?我尝试了很多选择,但我无法正确选择。
【问题讨论】: