Skip to content

Conversation

@Quix0r
Copy link
Contributor

@Quix0r Quix0r commented Nov 3, 2016

This may happen when the loaded input file is corrupt or damaged (for whatever reason). If this is not being tested, an endless loop may happen.

BTW: Please rename your Exception to e.g. PHPOfficeException to avoid confusion with the generic Exception from SPL.

With trim($data) == '' I wanted to make sure that not just only spaces are being provided. If that is okay, then I can change it to e.g. empty().

@PowerKiKi PowerKiKi merged commit 4b4831b into PHPOffice:develop Nov 16, 2016
@Quix0r Quix0r deleted the exception_invalid_parameter branch November 21, 2016 08:41
@Quix0r Quix0r restored the exception_invalid_parameter branch November 21, 2016 08:42
@Quix0r Quix0r deleted the exception_invalid_parameter branch November 21, 2016 08:42
Mirocow pushed a commit to Mirocow/PhpSpreadsheet that referenced this pull request Jan 16, 2017
github-merge-queue bot pushed a commit that referenced this pull request Jul 22, 2025
Fix #4537. PhpSpreadsheet currently changes apostrophes in text values to `'`. This is perfectly valid Xml. Issue was opened because R does not handle this correctly; this is unquestionably a bug on R's part. So I was not inclined to do anything about it. However ...

User suggested a change to how `htmlspecialchars` was called. Investigating the use of that routine in PhpSpreadsheet, I found that there was some double escaping going on for cells whose type was set to `TYPE_INLINE` - `htmlspecialchars` escaped the string correctly, but it was later written as Xml using a method which escaped the data a second time. So, a real bug in PhpSpreadsheet after all.

There was one call to `htmlspecialchars` in `Shared\XmlWriter`. I replaced `writeRaw(htmlspecialchars(...))` with `text(...)`. And one call in `Writer\Xlsx\Worksheet`, the source of the double escaping bug above; the call to `htmlspecialchars` can just be eliminated there.

Making those changes, the only remaining calls to `htmlspecialchars` are in `Writer\Html`, where they belong. As a bonus, apostrophes now wind up unescaped, so R will be satisfied (even though they should fix their bug).
BlackyTay pushed a commit to BlackyTay/PhpSpreadsheet that referenced this pull request Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants