Skip to content

Commit 5408965

Browse files
committed
Configuration patch.
Changelog excerpt: - Configuration multiline support added (necessary in order to properly facilitate the custom headers/footers feature introduced earlier today).
1 parent 848b307 commit 5408965

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
8585
[2022.06.16; Bug-fix; Maikuolan]: Warning generated since PHP 8.1 for parse functionality; Fixed.
8686

8787
[2022.08.18; Maikuolan]: Added L10N for Persian/Farsi, Hebrew, Malay, and Ukrainian.
88+
89+
[2022.09.26; Maikuolan]: Configuration multiline support added (necessary in order to properly facilitate the custom headers/footers feature introduced earlier today).

src/Loader.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The loader (last modified: 2022.09.22).
11+
* This file: The loader (last modified: 2022.09.26).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -281,6 +281,25 @@ public function __construct(
281281
/** Read the phpMussel configuration file. */
282282
if (strtolower(substr($this->ConfigurationPath, -4)) === '.ini') {
283283
$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+
}
284303
} elseif (preg_match('~\.ya?ml$~i', $this->ConfigurationPath)) {
285304
if ($Configuration = $this->readFile($this->ConfigurationPath)) {
286305
$this->YAML->process($Configuration, $this->Configuration);
@@ -1151,6 +1170,13 @@ public function updateConfiguration(): bool
11511170
} elseif ($DirValue === false) {
11521171
$Reconstructed .= sprintf("%s=false\r\n", $DirKey);
11531172
} 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+
11541180
$Reconstructed .= sprintf("%s='%s'\r\n", $DirKey, $DirValue);
11551181
} else {
11561182
$Reconstructed .= sprintf("%s=%s\r\n", $DirKey, $DirValue);

0 commit comments

Comments
 (0)