|
8 | 8 | * License: GNU/GPLv2
|
9 | 9 | * @see LICENSE.txt
|
10 | 10 | *
|
11 |
| - * This file: The loader (last modified: 2022.09.22). |
| 11 | + * This file: The loader (last modified: 2022.09.26). |
12 | 12 | */
|
13 | 13 |
|
14 | 14 | namespace phpMussel\Core;
|
@@ -281,6 +281,25 @@ public function __construct(
|
281 | 281 | /** Read the phpMussel configuration file. */
|
282 | 282 | if (strtolower(substr($this->ConfigurationPath, -4)) === '.ini') {
|
283 | 283 | $this->Configuration = parse_ini_file($this->ConfigurationPath, true);
|
| 284 | + |
| 285 | + /** Multiline support. */ |
| 286 | + if (is_array($this->Configuration)) { |
| 287 | + foreach ($this->Configuration as $CatKey => &$CatVal) { |
| 288 | + if (is_array($CatVal)) { |
| 289 | + foreach ($CatVal as $DirKey => &$DirVal) { |
| 290 | + if (!is_string($DirVal)) { |
| 291 | + continue; |
| 292 | + } |
| 293 | + $DirVal = str_replace( |
| 294 | + ["\\\\", '\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\e'], |
| 295 | + ["\\", "\0", "\7", "\8", "\t", "\n", "\x0B", "\x0C", "\r", "\x1B"], |
| 296 | + $DirVal |
| 297 | + ); |
| 298 | + } |
| 299 | + } |
| 300 | + } |
| 301 | + unset($DirVal, $DirKey, $CatVal, $CatKey); |
| 302 | + } |
284 | 303 | } elseif (preg_match('~\.ya?ml$~i', $this->ConfigurationPath)) {
|
285 | 304 | if ($Configuration = $this->readFile($this->ConfigurationPath)) {
|
286 | 305 | $this->YAML->process($Configuration, $this->Configuration);
|
@@ -1151,6 +1170,13 @@ public function updateConfiguration(): bool
|
1151 | 1170 | } elseif ($DirValue === false) {
|
1152 | 1171 | $Reconstructed .= sprintf("%s=false\r\n", $DirKey);
|
1153 | 1172 | } elseif (is_string($DirValue)) {
|
| 1173 | + /** Multiline support. */ |
| 1174 | + $DirValue = preg_replace('~[^\x00-\xFF]~', '', str_replace( |
| 1175 | + ["\\", "\0", "\7", "\8", "\t", "\n", "\x0B", "\x0C", "\r", "\x1B"], |
| 1176 | + ["\\\\", '\0', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\e'], |
| 1177 | + $DirValue |
| 1178 | + )); |
| 1179 | + |
1154 | 1180 | $Reconstructed .= sprintf("%s='%s'\r\n", $DirKey, $DirValue);
|
1155 | 1181 | } else {
|
1156 | 1182 | $Reconstructed .= sprintf("%s=%s\r\n", $DirKey, $DirValue);
|
|
0 commit comments