Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 406eb13

Browse files
committed
default parameters are escaped
1 parent ddc80bb commit 406eb13

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎src/Bootstrap/Configurator.php‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Configurator
6767

6868
public function __construct()
6969
{
70-
$this->parameters = $this->getDefaultParameters();
70+
$this->parameters = self::escape($this->getDefaultParameters());
7171
}
7272

7373

@@ -101,7 +101,7 @@ public function isDebugMode(): bool
101101
*/
102102
public function setTempDirectory(string $path)
103103
{
104-
$this->parameters['tempDir'] = $path;
104+
$this->parameters['tempDir'] = self::escape($path);
105105
return $this;
106106
}
107107

@@ -301,7 +301,7 @@ protected function getCacheDirectory(): string
301301
if (empty($this->parameters['tempDir'])) {
302302
throw new Nette\InvalidStateException('Set path to temporary directory using setTempDirectory().');
303303
}
304-
$dir = $this->parameters['tempDir'] . '/cache';
304+
$dir = DI\Helpers::expand('%tempDir%/cache', $this->parameters, true);
305305
Nette\Utils\FileSystem::createDir($dir);
306306
return $dir;
307307
}
@@ -330,4 +330,18 @@ public static function detectDebugMode($list = null): bool
330330
}
331331
return in_array($addr, $list, true) || in_array("$secret@$addr", $list, true);
332332
}
333+
334+
335+
/**
336+
* Expand counterpart.
337+
*/
338+
private static function escape($value)
339+
{
340+
if (is_array($value)) {
341+
return array_map([self::class, 'escape'], $value);
342+
} elseif (is_string($value)) {
343+
return str_replace('%', '%%', $value);
344+
}
345+
return $value;
346+
}
333347
}

0 commit comments

Comments
 (0)