From: Christian Weiske Date: Wed, 7 Sep 2016 05:44:39 +0000 (+0200) Subject: Quote values in .ini file X-Git-Tag: v0.0.1~3 X-Git-Url: https://git.cweiske.de/shpub.git/commitdiff_plain/cec131d5363dee47eed339881c1043c404094fb7?hp=f2a5805cac945d9dbadc37ff1c7946e938a0d9f1 Quote values in .ini file --- diff --git a/src/shpub/Config.php b/src/shpub/Config.php index 352ab99..d41e45d 100644 --- a/src/shpub/Config.php +++ b/src/shpub/Config.php @@ -65,7 +65,8 @@ class Config if ($hostVal == '') { continue; } - $str .= $hostProp . '=' . $hostVal . "\n"; + $str .= $hostProp + . '=' . static::quoteIniValue($hostVal) . "\n"; } } $cfgFilePath = $this->getConfigFilePath(); @@ -105,5 +106,13 @@ class Config } return null; } + + public static function quoteIniValue($val) + { + if (strpos($val, '=') === false) { + return $val; + } + return '"' . $val . '"'; + } } ?> diff --git a/src/shpub/Config/Endpoints.php b/src/shpub/Config/Endpoints.php index 2e58e7a..bc0510e 100644 --- a/src/shpub/Config/Endpoints.php +++ b/src/shpub/Config/Endpoints.php @@ -44,7 +44,7 @@ class Config_Endpoints $baseUrl = new \Net_URL2($server); $doc = new \DOMDocument(); - $doc->loadHTMLFile($server); + @$doc->loadHTMLFile($server); $sx = simplexml_import_dom($doc); if ($sx === false) { Log::err('Error loading URL: ' . $server); @@ -112,10 +112,11 @@ class Config_Endpoints file_put_contents( $file, - 'micropub=' . $this->micropub . "\n" - . 'media=' . $this->media . "\n" - . 'token=' . $this->token . "\n" - . 'authorization=' . $this->authorization . "\n" + 'micropub=' . Config::quoteIniValue($this->micropub) . "\n" + . 'media=' . Config::quoteIniValue($this->media) . "\n" + . 'token=' . Config::quoteIniValue($this->token) . "\n" + . 'authorization=' + . Config::quoteIniValue($this->authorization) . "\n" ); }