PHPOffice / PHPOffice/Common

Some control characters are not replaced and causes corrupted file

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
237
Forks
61
Avg merge
1h 2m
Merged PRs (30d)
1

Description

In Text.php, buildControlCharacters() constructs array of control characters, but only characters 0 - 19(without 9, 10, 13).

If i create Word2007 file with some other control character, for example 20, generated file is corrupted.

Sample:

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addText('control char 27(ESC):' . chr(27));
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('test.docx');

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Text.php at buildControlCharacters(), then reproduce the provided Word2007 example containing chr(27). Verify how control characters outside the currently handled range are processed, and confirm that the resulting test.docx opens without corruption.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.