From 65fa935f3f8bcfba1bcba8cd02fcbec76d720aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Salom=C3=A9?= Date: Thu, 18 Apr 2024 21:35:20 +0200 Subject: [PATCH] Escape text with newlines --- CHANGELOG.md | 5 +++++ src/Output/DotEscaper.php | 2 +- tests/Output/DotEscaperTest.php | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57b7bb0..d64a32d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.0.1 (2024-04-25) +------------------ + +* [bug] Escape text with newlines + 2.0.0 (23/10/2022) ------------------ diff --git a/src/Output/DotEscaper.php b/src/Output/DotEscaper.php index 68d4526..b2b1523 100644 --- a/src/Output/DotEscaper.php +++ b/src/Output/DotEscaper.php @@ -49,6 +49,6 @@ private function needsEscaping(string $value): bool return true; } - return preg_match('/[{}<> "#\-:\\\\\\/.,]/', $value) || '' === $value; + return preg_match('/[\n{}<> "#\-:\\\\\\/.,]/', $value) || '' === $value; } } diff --git a/tests/Output/DotEscaperTest.php b/tests/Output/DotEscaperTest.php index 158724c..4794615 100644 --- a/tests/Output/DotEscaperTest.php +++ b/tests/Output/DotEscaperTest.php @@ -51,6 +51,7 @@ public function provideEscape(): array ['edge', '"edge"'], ['', '""'], ['2', '2'], + ["foo\nbar", "\"foo\nbar\""], ]; }