Skip to content

Commit 2513e54

Browse files
Owen LeibmanOwen Leibman
authored andcommitted
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.
1 parent a10fe82 commit 2513e54

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tests/PhpWord/Escaper/RtfEscaper2Test.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
1616
*/
1717

18+
namespace PhpOffice\PhpWord\Escaper;
19+
1820
/**
19-
* Test class for PhpOffice\PhpWord\Writer\RTF\Style subnamespace
21+
* Test class for PhpOffice\PhpWord\Escaper\RTF
2022
*/
2123
class RtfEscaperTest extends \PHPUnit\Framework\TestCase
2224
{

tests/PhpWord/Writer/RTF/ElementTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
*/
2525
class ElementTest extends \PHPUnit\Framework\TestCase
2626
{
27-
public function removeCr($field) {
27+
public function removeCr($field)
28+
{
2829
return str_replace("\r\n", "\n", $field->write());
2930
}
3031
/**

0 commit comments

Comments
 (0)