PHP Classes

data leak

Recommend this page to a friend!

      eiseXLSX  >  All threads  >  data leak  >  (Un) Subscribe thread alerts  
Subject:data leak
Summary:updating shared strings creates unwanted results
Messages:2
Author:Philipp Strazny
Date:2018-07-18 18:12:00
 

  1. data leak   Reply   Report abuse  
Picture of Philipp Strazny Philipp Strazny - 2018-07-18 18:12:00
If a file contains the same string in multiple cells, Excel stores just one value in a "shared string" and each cell then just contains a reference to that shared string.
The current code updates string values by (a) retrieving the shared string and (b) changing the value of that shared string.
This produces unwanted results, because changing one cell that shares its string with other cells inadvertently changes the values of the cells that also refer to this shared string.
To fix this, I modified line 210 in the data() function
if (isset($c->v[0]))....
to
if (!$data && isset($c->v[0]))....
If new data is supplied for a given cell, this will create a new shared string for that cell and enter the value into that new shared string. This prevents that other cells are affected.
I'm not sure if this creates orphaned shared strings that should be deleted or if Excel has cleanup functionality to delete shared string that nothing refers to. But it appears to work.

  2. Re: data leak   Reply   Report abuse  
Picture of Ilya Eliseev Ilya Eliseev - 2018-10-09 15:42:28 - In reply to message 1 from Philipp Strazny
Hello Philipp,

thanks for your report. I'm not sure that MS Excel uses this "shared" functionality as specified in SpreadsheetML specs, even when you copy/paste sheet data in one workbook. It was checked multiple times. The error you report mostly appears in documents that's been edited with other spreadsheet editors or even eiseXLSX (especially with cloneSheet method).

Anyway, maybe you're right, but I'm a bit uncertain about the implementation of your fix in the next version of eiseXLSX. The reason is because sometimes eiseXLSX is used for large amount of write operations on non-empty sheets and the solution you offer may unexpectedly flood sharedStrings.xml file.