From 3bcf0ff764e38f7e45904c57ca218446179e8c2c Mon Sep 17 00:00:00 2001 From: Paul Vogel Date: Mon, 5 Mar 2018 03:32:47 +0100 Subject: [PATCH] [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 --- .../src/main/resources/php/ObjectSerializer.mustache | 2 +- .../petstore/php/SwaggerClient-php/lib/ObjectSerializer.php | 2 +- .../client/petstore/php/SwaggerClient-php/phpunit.xml.dist | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index f07a4d18cc0a..460b69b705bb 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -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(), ''); } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 1f7e3f3d6148..6a4225ff5d5a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -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(), ''); } diff --git a/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist b/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist index c12ee1484773..cadedbc24690 100644 --- a/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist +++ b/samples/client/petstore/php/SwaggerClient-php/phpunit.xml.dist @@ -14,8 +14,8 @@ - ./lib/Api - ./lib/Model + ./lib\Api + ./lib\Model