Thank you.  The developer I'm working with did run our code through the
debugger and we had a better understanding of how the value of "text" was
being populated and changing over time.

Scott

On Mon, Mar 25, 2019 at 3:31 PM Andreas Beeker <[email protected]> wrote:

> Hi Scott,
>
> > I don’t understand where the values of text.length() and string.length()
> are coming from.
> The values are parameters of method "checkMaxTextSize",
>
> Where is "checkMaxTextSize" called and what are the parameters?
> Please use a decent IDE, and check the references to the method!
>
> Ok, the method is called in XSSFExcelExctractor on several locations.
> e.g.
> line 165: String contents = cell.getCellFormula();
> line 166: checkMaxTextSize(text, contents);
>
> So as the exception says, it checks the overall size ... so <text> must be
> something accumulated and the checkMaxTextSize is used, to see if that
> little bit more of <contents> is breaking the threshold.
>
> What else is accumulated?
> That depends on how you configured the extractor ... just check its
> source! [1]
>
> > I'm getting this exception and I don't know what (in the .zip file) is
> > causing this to be thrown.
> So your file seems to be nearly empty?
> Maybe select everything and remove the comments?
>
> To find out what really is causing this, I would copy the extractor class
> and add some counters -
> just use a debugger and give it a try!
>
> Andi
>
>
>
>
> [1]
>
> if (formulasNotResults) {
>     String contents = cell.getCellFormula();
>     checkMaxTextSize(text, contents);
>
> ...
>
> if(includeCellComments && comment != null) {
>     // Replace any newlines with spaces, otherwise itbreaks the output
> String commentText = comment.getString().getString().replace('\n', ' ');
>     checkMaxTextSize(text, commentText);
>
> ...
>
> private void handleStringCell(StringBuilder text, Cell cell) {
>     String contents = cell.getRichStringCellValue().getString();
>     checkMaxTextSize(text, contents);
>
> ...
>
> if (type == CellType.NUMERIC) {
>     CellStyle cs = cell.getCellStyle();
>
>     if (cs != null && cs.getDataFormatString() != null) {
>         String contents =
> formatter.formatRawCellContents(cell.getNumericCellValue()...);
>         checkMaxTextSize(text, contents);
>
> ...
>
> // No supported styling applies to this cell String contents =
> ((XSSFCell)cell).getRawValue();
> if (contents != null) {
>     checkMaxTextSize(text, contents);
>
>
> On 25.03.19 16:17, Scott Gardner wrote:
> > I understand that, but specifically what is it in a .zip file that will
> > cause this if statement to throw the IllegalStateException?  I don’t
> > understand where the values of text.length() and string.length() are
> coming
> > from.
> >
> >        int size = text.length() + string.length();
> >
> >        if(size > ZipSecureFile.getMaxTextSize()) {
> >
> > I'm getting this exception and I don't know what (in the .zip file) is
> > causing this to be thrown.
> >
> > The text would exceed the max allowed overall size of extracted text. By
> > default this is prevented as some documents may exhaust available memory
> > and it may indicate that the file is used to inflate memory usage and
> thus
> > could pose a security risk. You can adjust this limit via
> > ZipSecureFile.setMaxTextSize() if you need to work with files which have
> a
> > lot of text. Size: 10485785, limit: MAX_TEXT_SIZE: 10485760
> >
> >
> > On 2019/03/22 19:11:17, "pj.fanning" <[email protected]> wrote:
> >> The code is there to protect against
> > https://en.wikipedia.org/wiki/Zip_bomb>
>
>

Reply via email to