naruto-lgtm opened a new pull request, #1580:
URL: https://github.com/apache/poi/pull/1580

   Repro: put a cell comment on row 1 of an .xls, call 
`sheet.removeRow(sheet.getRow(0))` and write the workbook. The comment text is 
still in the Workbook stream, and after reopening `getCellComments()` returns 
it on A1, which is now an empty cell. An application that drops rows before 
passing a workbook on (filtering out personal data, redaction) ships the 
comments of every removed row (CWE-212).
   Cause: `HSSFSheet.removeRow` removes the row and cell value records but 
never touches the drawing, so the comment's NoteRecord, Obj/TXO records and 
text stay in the patriarch. `XSSFSheet.removeRow` already removes the comments 
of the removed row (`TestXSSFSheet.testRemoveRowWithCommentAndGapAbove`), so 
the two implementations of `Sheet.removeRow` disagree.
   Fix: remove the top-level comments anchored to the removed row through 
`HSSFPatriarch.removeShape`, the path `HSSFCell.removeCellComment` uses, so the 
NoteRecord goes with them. The patriarch is only looked up, never created, so 
sheets without a drawing are untouched; a sheet that has one gets its drawing 
aggregated, as `shiftRows` already does. Hyperlinks on the removed row are left 
as they are, matching XSSF. `TestHSSFSheet.removeRowRemovesComments` fails 
before the change; the hssf usermodel/model and ss suites pass apart from 
`TestDateSerialRange.testEdgesOfTheRange`, which fails on unpatched trunk as 
well.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to