Modern Apps git

← Modern-Apps.git

office: fix swapped row/column repeat caps in ODS parser

Commit
d2dac0177dc3b1a27c64d6f772bc9504c4ea7bd4
Author
Vayun Mathur <[email protected]>
When
2026-11-07 20:10 UTC (28 days ago)
Parents
23b1859
Symptom: ODS sheets with more than 200 repeated columns lost
column widths and hidden-column flags past column 200, while
repeated rows were allowed to expand to 1000 rows instead of
the intended 200-row guard (memory bloat on hostile files).

Root cause: applySheetColumn capped repeats with
MAX_REPEATED_ROWS and applySheetRow capped with
MAX_REPEATED_COLS; the two constants were swapped at the call
sites.

Fix: columns cap with MAX_REPEATED_COLS (1000), rows with
MAX_REPEATED_ROWS (200).

Verification: part of OdfParser2SheetTest run (see CSV commit);
new repeated_rows_and_columns_use_their_own_caps test asserts
300 repeated columns survive and 300 repeated rows cap at 200.

Diff

office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt b/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.ktindex e7f624e2df..e44a51416f 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt+++ b/office/src/main/java/com/vayunmathur/office/odf/OdfParserSheet.kt@@ -136,7 +136,7 @@ private fun OdfParser.applySheetColumn(     val styleName = getAttr(parser, "style-name")     val width = resolveStyle(styleName, styles).columnWidth     val hidden = getAttr(parser, "visibility").let { it == "collapse" || it == "filter" }-    repeat(repeated.coerceAtMost(MAX_REPEATED_ROWS)) {+    repeat(repeated.coerceAtMost(MAX_REPEATED_COLS)) {         if (hidden) hiddenCols.add(acc.colIndex)         columnWidths.add(width); acc.colIndex++     }@@ -156,7 +156,7 @@ private fun OdfParser.applySheetRow(     val rh = resolveStyle(styleName, styles).rowHeight     val hidden = getAttr(parser, "visibility").let { it == "collapse" || it == "filter" }     val cells = parseSpreadsheetCells(parser, styles, numberStyles)-    repeat(repeated.coerceAtMost(MAX_REPEATED_COLS)) {+    repeat(repeated.coerceAtMost(MAX_REPEATED_ROWS)) {         if (hidden) hiddenRows.add(rows.size)         rows.add(OdfRow(cells)); rowHeights.add(rh)     }