Skip to content

Commit

Permalink
[PHP] Add path & file separator (/) to return the correct path when d…
Browse files Browse the repository at this point in the history
…eserializing 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
  • Loading branch information
pavog authored and wing328 committed Mar 5, 2018
1 parent 8e0a0eb commit 3bcf0ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class ObjectSerializer
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) &&
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 {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static function deserialize($data, $class, $httpHeaders = null)
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) &&
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 {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib/Api</directory>
<directory suffix=".php">./lib/Model</directory>
<directory suffix=".php">./lib\Api</directory>
<directory suffix=".php">./lib\Model</directory>
</whitelist>
</filter>
</phpunit>

0 comments on commit 3bcf0ff

Please sign in to comment.