[PHP] Add path & file separator (/) to return the correct path when deserializing a file (#7671)

* Add path & file separator (/) to return the correct path

Add the separator between the tempFolderPath and the sanitized filename so that the path to the file is correct.

(Fixes #7670)

* Remove separator from generated file

* Add separator

Add the separator between the tempFolderPath and the sanitized filename so that the path to the file is correct.

(Fixes #7670)

* Update sample code

Via ./bin/php-petstore.sh
This commit is contained in:
Paul Vogel 2018-03-05 03:32:47 +01:00 committed by William Cheng
parent 8e0a0ebd62
commit 3bcf0ff764
3 changed files with 4 additions and 4 deletions

View File

@ -261,7 +261,7 @@ class ObjectSerializer
// determine file name // determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && if (array_key_exists('Content-Disposition', $httpHeaders) &&
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . self::sanitizeFilename($match[1]); $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]);
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
} }

View File

@ -271,7 +271,7 @@ class ObjectSerializer
// determine file name // determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && if (array_key_exists('Content-Disposition', $httpHeaders) &&
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . self::sanitizeFilename($match[1]); $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]);
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
} }

View File

@ -14,8 +14,8 @@
<filter> <filter>
<whitelist processUncoveredFilesFromWhitelist="true"> <whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib/Api</directory> <directory suffix=".php">./lib\Api</directory>
<directory suffix=".php">./lib/Model</directory> <directory suffix=".php">./lib\Model</directory>
</whitelist> </whitelist>
</filter> </filter>
</phpunit> </phpunit>