Php wkhtmltopdf-URL中的空格
使用wkhtmltopdf时,当URL包含Php wkhtmltopdf-URL中的空格,php,url,wkhtmltopdf,url-encoding,wkhtmltoimage,Php,Url,Wkhtmltopdf,Url Encoding,Wkhtmltoimage,使用wkhtmltopdf时,当URL包含%20时,我无法生成图像 当通过命令行在本地执行相同的命令时,这不是问题 一旦它上线,有没有办法让它工作 到目前为止,我的代码是: <?php $url = $_GET['url']; // Website URL to Create Image $name = $_GET['img']; // Output Image Name $command = "/usr/local/bin/wkhtmltoimage --no-images -
%20
时,我无法生成图像
当通过命令行在本地执行相同的命令时,这不是问题
一旦它上线,有没有办法让它工作
到目前为止,我的代码是:
<?php
$url = $_GET['url']; // Website URL to Create Image
$name = $_GET['img']; // Output Image Name
$command = "/usr/local/bin/wkhtmltoimage --no-images --crop-w 580";
$dir_img = "images/"; // Image files will be saved here
$ex_cmd = "$command $url " . $dir_img . $name;
$output = shell_exec($ex_cmd);
?>
除非URL中有一个%20
,否则此操作正常
我需要截图的页面必须在其URL中包含
%20
,因此删除该页面的函数将不是一个解决方案。不幸的是,您必须避开您的论点,否则您的代码中存在巨大的安全漏洞:
$url = escapeshellarg($_GET['url']); // Website URL to Create Image
$name = escapeshellarg($_GET['img']); // Output Image Name
$command = "/usr/local/bin/wkhtmltoimage --no-images --crop-w 580";
$dir_img = "images/"; // Image files will be saved here
$ex_cmd = "$command $url " . $dir_img . $name;
$output = shell_exec($ex_cmd);
这只是为了让您开始,您还必须检查$\u get['url']
是url,而不是eg/config/database.php
,并且$\u get['img']
也必须进行消毒