diff --git a/src/Formatter/EdifactFormatter.php b/src/Formatter/EdifactFormatter.php index de70b96..c55a5b9 100644 --- a/src/Formatter/EdifactFormatter.php +++ b/src/Formatter/EdifactFormatter.php @@ -75,12 +75,14 @@ private function escapeString(string $string): string $this->unaSegment->escapeCharacter(), $this->unaSegment->componentSeparator(), $this->unaSegment->elementSeparator(), + $this->unaSegment->segmentTerminator(), '\\n', ], [ $this->unaSegment->escapeCharacter() . $this->unaSegment->escapeCharacter(), $this->unaSegment->escapeCharacter() . $this->unaSegment->componentSeparator(), $this->unaSegment->escapeCharacter() . $this->unaSegment->elementSeparator(), + $this->unaSegment->escapeCharacter() . $this->unaSegment->segmentTerminator(), '', ], $string diff --git a/tests/Formatter/EdifactFormatterTest.php b/tests/Formatter/EdifactFormatterTest.php index 3d2d510..194d897 100644 --- a/tests/Formatter/EdifactFormatterTest.php +++ b/tests/Formatter/EdifactFormatterTest.php @@ -55,9 +55,9 @@ public function test_remove_loose_ends_string(): void public function test_escaping_string(): void { $unaSegment = UnaSegment::getDefault(); - $expectedString = "???:?+" . $unaSegment->segmentTerminator(); + $expectedString = "???:?+?'" . $unaSegment->segmentTerminator(); - $segment = AbstractSegmentTestSegment::fromAttributes('?:+'); + $segment = AbstractSegmentTestSegment::fromAttributes("?:+'"); $this->assertSame($expectedString, (new EdifactFormatter($unaSegment))->format($segment)); }