donatj / mock-webserver

Simple mock web server in PHP for unit testing.
MIT License
131 stars 21 forks source link

Please add escapeshellarg around script path #53

Closed SiestaCat closed 1 year ago

SiestaCat commented 1 year ago

Hello

I get this error in php built-in server:

<br />
<b>Warning</b>:  Unknown: failed to open stream: No such file or directory in <b>Unknown</b> on line <b>0</b><br />
<br />
<b>Fatal error</b>:  Unknown: Failed opening required 'D:\MY' (include_path='D:\pear\pear;C:\xampp\php\PEAR') in <b>Unknown</b> on line <b>0</b><br />

Because the script path have white spaces. For example:

D:\MY PROJECT\symfony\vendor\donatj\mock-webserver\src\..\server\server.php

Guilty line: vendor\donatj\mock-webserver\src\MockWebServer.php:57 $cmd = "php -S {$this->host}:{$this->port} " . $script;

Please, can you use escapeshellarg or similar around $script variable?

For example:

$cmd = "php -S {$this->host}:{$this->port} " . escapeshellarg($script);

Thanks a lot

donatj commented 1 year ago

Looks like this issue cropped up with the recent addition of Windows support.

Thanks for the report, looking into it. Should have a fix soon.

donatj commented 1 year ago

Fixed and released in https://github.com/donatj/mock-webserver/releases/tag/v2.6.2