Skip to content

Commit a5509c9

Browse files
author
Ben Burleson
committed
Apply patch from docusign#41
1 parent 7c16479 commit a5509c9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/ObjectSerializer.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static function sanitizeForSerialization($data)
7979
*
8080
* @return string the sanitized filename
8181
*/
82-
public function sanitizeFilename($filename)
82+
public static function sanitizeFilename($filename)
8383
{
8484
if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) {
8585
return $match[1];
@@ -251,14 +251,17 @@ public static function deserialize($data, $class, $httpHeaders = null)
251251
} else {
252252
return null;
253253
}
254-
} elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
254+
} elseif ($class === 'DateTime' || in_array(strtolower($class), ['bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
255+
if ($class !== 'DateTime') {
256+
$class = strtolower($class);
257+
}
255258
settype($data, $class);
256259
return $data;
257260
} elseif ($class === '\SplFileObject') {
258261
// determine file name
259262
if (array_key_exists('Content-Disposition', $httpHeaders) &&
260263
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
261-
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . sanitizeFilename($match[1]);
264+
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . self::sanitizeFilename($match[1]);
262265
} else {
263266
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
264267
}

0 commit comments

Comments
 (0)