DEV Community

ANIRUDDHA  ADAK
ANIRUDDHA ADAK Subscriber

Posted on

270 Merged PRs in GenOffice: How I Hardened an Open-Source AI Office Suite

From single-quoted XML quirks to non-finite geometry guards — the story behind 270 merged pull requests in genspark-ai/genoffice, the world's first full-featured open-source AI Office suite.

GenOffice is a free, open-source alternative to Microsoft Office (macOS / Windows / Linux). It opens and saves native .docx, .xlsx, .pptx, edits PDF, Markdown and HTML, and puts a reviewable AI agent next to every document. Real formats, byte-preserving. Local by design.

I contributed 270 merged PRs (PR #131 → #733), backed by ~268+ commits in my local clone. Almost all are fix: / test: — small, reviewable, CI-green hardening patches across Docs, Sheets, Slides, PDF, DOCX engine, PPTX engine, xlsx-gateway, html2docx, pdf2docx, shell, CLI, electron-utils, ai-provider, ai-search, and a11y/i18n.

Repo: https://github.com/genspark-ai/genoffice

How it started

I came for the file-format rabbit hole and stayed for the edge cases. Office files are hostile inputs in the wild: single-quoted attributes, uppercase True, paired protection tags, BOM-less UTF-16 CSVs, backslash pptx targets, lowercase xlsx refs, broken slide sizes, 1904 date systems. Each one breaks a naive parser. My loop became: reproduce → clamp/validate/normalize → add regression test → keep the diff minimal.

Early work (#131–#160) was Sheets/Slides streaming and save reliability: Ctrl+F beyond the loaded window, filter-hidden rows in find, whole-file error checking on streamed workbooks, row-batch sidecar reads, temp-file TTL sweeps, serialized concurrent saves, in-flight save waits, SSE reader release + malformed-frame skips, IPC failure surfacing.

What I actually did — by theme

1. Parser hardening: read what Word really writes

  • DOCX: single-quoted fldCharType, protection attrs, checkbox glyphs, footnote separators, TOC tab stops, xml:space, numeric char refs, NBSP edges, paired tags, vanish/footnote bold variants.
  • PPTX: single-quoted slide ids / hyperlink r:id / showMasterSp, preset colors case-insensitive, true/True table flags, tab stops as tabs, slides in presentation order.
  • XLSX / CSV: lowercase cell refs, escaped quotes + quote-state across lines, BOM-less UTF-16, over-precision integers as text, delimiter sniffing that ignores single-column prose.

2. Numeric safety: kill NaN / Infinity / overflow

A huge slice is one pattern: non-finite in → sane out. Chart axis min/max, font sizes, ink geometry, connector widths, border widths, rect dims, table colSpan, EQ columns, slide-id scans, CSV row/col caps, bitmap dims, outline JSON caps, SSE buffers, tool-call counts, chat limits, timeline limits, print geometry, AI length parsers (parseTableLength #730). Boring? Yes. That's why it matters — one NaN can DoS a renderer or corrupt an export.

3. Security + IPC + SSRF + save reliability

Traversal-id rejection, canonical path comparison for tabs, renderer file resolution hardening, SSRF maxRedirects normalization, MCP host/file checks, sheet-address hardening, zip-handle closing + central-directory validation, protection spinCount clamping, lazy-media hash/part-path hardening, redaction-region caps, outline-depth caps, link-rect validation, serialized saves (#155), in-flight save waits (#149), SSE cleanup (#150/#151).

4. i18n / a11y / RTL

Bidi direction tests, Southeast Asian + CJK word counts, kana/radical/astral-CJK font mapping, hardcoded cm strings moved into i18n (#733), existing i18n keys for aria labels, dialog role/focus/escape, diagram preview keyboard operable, toasts + outline empty-state announcements, localized labels, RTL-aware AI panels.

5. Tests that lock it in

Touched-blocks coverage, bidi units, east-asian rFonts round-trip, CSV import round-trip, formula-shift + csv-import units, executor/units/op-docs sync, deck-spec + layout-audit, legacy doc/ppt + html2docx tables, CLI help/registry/README/skill sync, xlsx-gateway + pptx-ops wired into CI.

6. Features (small, sharp)

  • feat(sheets): infer table range from current region (fixes #298) (#371)
  • feat(sheets): cross-highlight the active cell's row and column (#132)
  • feat(pdf): add print range dialog (all/current/custom)
  • feat(markdown): add document outline sidebar with click-to-jump
  • feat(ai-search): add Tavily web search fallback via TAVILY_API_KEY
  • feat(docs): per-side and inside table borders in ribbon + RTL-aware panels

Highlights (12 to start with)

The full list — all merged GenOffice PRs

Every PR below is merged in genspark-ai/genoffice by @aniruddhaadak80. Count in this post: 270 (complete via GitHub Search API, 719 total merged PRs of mine across 62 repos).

a11y (1)

agent-core (1)

ai-panels (3)

ai-provider (21)

ai-search (8)

cli (5)

contributing (1)

dialogs (1)

docs (24)

docx (19)

docx-engine (11)

electron-utils (9)

file-parse (8)

font-metrics (1)

general (2)

html (3)

html2docx (7)

i18n (2)

markdown (11)

pdf (18)

pdf2docx (9)

pipelines (2)

pptx (7)

pptx-engine (6)

pptx-ops (4)

pptx-render (4)

print-range (1)

project-store (3)

sheets (37)

shell (12)

slides (21)

tests (1)

xlsx-gateway (7)

What I learned

  1. Real-world files don't follow the spec. If Word can emit it, you must parse it: single quotes, uppercase booleans, paired tags, backslashes.
  2. Clamp at the boundary, not in the middle. Validate IPC, IDs, sizes, counts, and numerics where they enter — renderers stay simple.
  3. Non-finite is a vulnerability class. NaN/Infinity handling deserves the same discipline as XSS/traversal.
  4. Tiny PRs merge faster. One fix + one test beats a 2,000-line refactor.
  5. A11y/i18n is correctness. If a screen reader or RTL user can't use it, it's broken.

What's next

Continuing the hardening pass (latest: #730 AI parseTableLength caps, #733 cm→i18n, #689 CLI JPEG validation, #687 media-settings tolerance, #684 SVG flattening). If you maintain an Office parser, start with hostile-input fuzzing around numbers, quotes, and encodings — you'll find bugs in an afternoon.


All PRs merged in https://github.com/genspark-ai/genoffice — author: https://github.com/aniruddhaadak80

Top comments (0)