From 2513e545406c81a117af7166cc3a053cc01f68e4 Mon Sep 17 00:00:00 2001 From: Owen Leibman Date: Sat, 16 Nov 2019 23:20:02 -0800 Subject: [PATCH] Errors in RTF Escaping 1. Codes meant to be in hex are specified in decimal. Consequently characters which don't need escaping are escaped. 2. Special handling (prepend backslash) needed for {, }, and . RTF docs generated with those characters cannot be opened in Word. 3. Tab character needs to be escaped as \tab. RTF docs drop these characters. While running test suite, found that Writer/RTF/ElementTest was coded only for Unix line endings, and fails on Windows. Changed so that it would work on either. --- tests/PhpWord/Escaper/RtfEscaper2Test.php | 4 +++- tests/PhpWord/Writer/RTF/ElementTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/PhpWord/Escaper/RtfEscaper2Test.php b/tests/PhpWord/Escaper/RtfEscaper2Test.php index b16dc469..27e8a985 100644 --- a/tests/PhpWord/Escaper/RtfEscaper2Test.php +++ b/tests/PhpWord/Escaper/RtfEscaper2Test.php @@ -15,8 +15,10 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +namespace PhpOffice\PhpWord\Escaper; + /** - * Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace + * Test class for PhpOffice\PhpWord\Escaper\RTF */ class RtfEscaperTest extends \PHPUnit\Framework\TestCase { diff --git a/tests/PhpWord/Writer/RTF/ElementTest.php b/tests/PhpWord/Writer/RTF/ElementTest.php index 4c9dfc5e..67a319e6 100644 --- a/tests/PhpWord/Writer/RTF/ElementTest.php +++ b/tests/PhpWord/Writer/RTF/ElementTest.php @@ -24,7 +24,8 @@ use PhpOffice\PhpWord\Writer\RTF; */ class ElementTest extends \PHPUnit\Framework\TestCase { - public function removeCr($field) { + public function removeCr($field) + { return str_replace("\r\n", "\n", $field->write()); } /**