diff --git a/src/Printers/CliPrinter.php b/src/Printers/CliPrinter.php index e3efed9..dc8a2d0 100644 --- a/src/Printers/CliPrinter.php +++ b/src/Printers/CliPrinter.php @@ -204,7 +204,12 @@ public function optionsHtml(MessageLogged $messageLogged): string return collect($options)->merge( $messageLogged->context() // @phpstan-ignore-line )->reject(fn (mixed $value, string|int $key) => is_int($key) && is_null($value)) - ->map(fn (mixed $value) => is_string($value) ? e($value) : var_export($value, true)) + ->map(fn (array|string|null $value) => is_array($value) ? + collect($value)->map(fn (string|null $value) => is_string($value) ? e($value) : var_export($value, true))->implode(', ') : + $value + ) + ->map(fn (mixed $value) => is_string($value) ? e($value): $value) + ->map(fn (mixed $value) => is_string($value) ? $value : var_export($value, true)) ->map(fn (string $value, string|int $key) => is_string($key) ? "$key: $value" : $value) ->map(fn (string $value) => "$value") ->implode(' • '); diff --git a/tests/Unit/CliPrinterTest.php b/tests/Unit/CliPrinterTest.php index b7add12..7bec266 100644 --- a/tests/Unit/CliPrinterTest.php +++ b/tests/Unit/CliPrinterTest.php @@ -141,3 +141,33 @@ EOF ); }); + +test('escaping an array of html options', function () { + $output = output([ + 'message' => 'Context that contains html', + 'level_name' => 'info', + 'datetime' => '2021-01-01 00:00:00', + 'context' => [ + 'html' => ['
'], + '__pail' => [ + 'origin' => [ + 'type' => 'http', + 'method' => 'GET', + 'path' => '/logs', + 'auth_id' => null, + 'auth_email' => null, + ], + ], + ], + ]); + + $html = e(''); + + expect($output)->toBe(<<