git.cweiske.de
/
shpub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix JSON HTML content sending, according to new tests
[shpub.git]
/
src
/
shpub
/
Config.php
diff --git
a/src/shpub/Config.php
b/src/shpub/Config.php
index 044b1504ab4ff87c7b21621d079e4187176bb155..2ca7d9adeea3c376196ebe0972fd313d53879ba0 100644
(file)
--- a/
src/shpub/Config.php
+++ b/
src/shpub/Config.php
@@
-12,9
+12,12
@@
class Config
*/
public $host;
*/
public $host;
+ public $debug = false;
+
protected function getConfigFilePath()
{
if (!isset($_SERVER['HOME'])) {
protected function getConfigFilePath()
{
if (!isset($_SERVER['HOME'])) {
+ Log::err('Cannot determine home directory');
return false;
}
return false;
}
@@
-64,13
+67,14
@@
class Config
if ($hostVal == '') {
continue;
}
if ($hostVal == '') {
continue;
}
- $str .= $hostProp . '=' . $hostVal . "\n";
+ $str .= $hostProp
+ . '=' . static::quoteIniValue($hostVal) . "\n";
}
}
$cfgFilePath = $this->getConfigFilePath();
$cfgDir = dirname($cfgFilePath);
if (!is_dir($cfgDir)) {
}
}
$cfgFilePath = $this->getConfigFilePath();
$cfgDir = dirname($cfgFilePath);
if (!is_dir($cfgDir)) {
- mkdir($cfgDir);
+ mkdir($cfgDir
, 0700
);
}
file_put_contents($cfgFilePath, $str);
//contains sensitive data; nobody else may read that
}
file_put_contents($cfgFilePath, $str);
//contains sensitive data; nobody else may read that
@@
-84,7
+88,7
@@
class Config
}
foreach ($this->hosts as $key => $host) {
if ($host->default) {
}
foreach ($this->hosts as $key => $host) {
if ($host->default) {
- return $
host
;
+ return $
key
;
}
}
}
}
@@
-104,5
+108,18
@@
class Config
}
return null;
}
}
return null;
}
+
+ public static function quoteIniValue($val)
+ {
+ if (strpos($val, '=') === false) {
+ return $val;
+ }
+ return '"' . $val . '"';
+ }
+
+ public function setDebug($debug)
+ {
+ $this->debug = $debug;
+ }
}
?>
}
?>