Modern Apps git

← Modern-Apps.git

office: fix applySvgCommand returning stale token index

Commit
8ea9da4fc2c56f83310ef931437f12be53836300
Author
Vayun Mathur <[email protected]>
When
2026-11-06 18:15 UTC (29 days ago)
Parents
90ea071
827ba5556 extracted the SVG path loop into applySvgCommand but kept a snapshot 'var idx = i' that known commands never advance (they move path.i internally). Returning the stale snapshot re-parsed the same tokens forever; return path.i instead, and i + 1 for unknown commands so the loop makes progress (verified: 3 svg-path tests fail without, pass with).

(cherry picked from commit 00ee439040852c14f0f5f6f2c3da51471fa86e05)

Diff

office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt b/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.ktindex b70b6338b7..0f3b84413e 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt+++ b/office/src/main/java/com/vayunmathur/office/odf/OdfParserSlides.kt@@ -668,7 +668,6 @@ private fun OdfParser.applySvgCommand(     rel: Boolean,     path: SvgPathAcc, ): Int {-    var idx = i     when (cmd.uppercaseChar()) {         'M' -> applySvgMove(path, rel)         'L' -> applySvgLine(path, rel)@@ -677,9 +676,11 @@ private fun OdfParser.applySvgCommand(         'Q', 'T' -> applySvgQuad(path, cmd, rel)         'A' -> applySvgArc(path, rel)         'Z' -> applySvgClose(path)-        else -> idx+++        // Unknown command: skip one token so the loop always makes progress.+        // (Callers pass path.i here, so returning i + 1 advances past the junk token.)+        else -> return i + 1     }-    return idx+    return path.i }  private fun applySvgMove(path: SvgPathAcc, rel: Boolean) {