Skip to content

Boolean run property w:val="0" dropped on save — bold spreads to untouched runs #173

Description

@kiki830621

Problem

Original observation(2026-08-28 session,編輯一份會議摘要 docx):
原始檔 bold runs = 13(僅標題/作者/機構列);經 open_document → replace_text ×4 → save_document 一輪後,所有段落(含完全未觸及的 Keywords / Type / Research area 段)全部變粗體(bold runs = 21)。

機制(最小重現已確認):save round-trip 把顯式關閉的 boolean run property <w:b w:val="0"/> 重新序列化成 <w:b/>(開)。OOXML 的 on/off property 語意是 presence + w:val<w:b w:val="0"/> = 關;presence-based 解析把 w:val 丟掉後,語意翻轉成開。推測同族 boolean property(bCs / i / iCs / strike / vanish …)都受影響。

Type

bug

Repro(最小、確定性)

  1. 建 docx,word/document.xml body:

    <w:p><w:r><w:rPr><w:b w:val="0"/></w:rPr><w:t>alpha beta</w:t></w:r></w:p>
    <w:p><w:r><w:t>gamma delta</w:t></w:r></w:p>
  2. open_documentreplace_text("gamma" → "GAMMA")(完全不碰 P0)→ save_documentclose_document

  3. 讀回 word/document.xml

Expected

P0 的 <w:b w:val="0"/> 原樣保留,或至少語意等價(非粗體)。

Actual

P0 變成 <w:rPr><w:b/></w:rPr>——未觸及的 run 由「顯式非粗體」翻轉為「粗體」。實測輸出:

<w:body><w:p><w:r><w:rPr><w:b/></w:rPr><w:t>alpha beta</w:t></w:r></w:p><w:p><w:r><w:t>GAMMA delta</w:t></w:r></w:p>…

(save 時的既知 normalization——注入 sectPr、補 xmlns——不在本 issue 範圍。)

Impact

  • 靜默資料毀損:Word 產出的文件常帶 w:val="0" 顯式關閉;任何 mutation + save 後格式翻轉,工具鏈全程回報成功。
  • 實際案例:投稿用摘要 docx 全文變粗體,最後靠 zip/XML 手術才還原。

Environment

che-word-mcp(plugin cache 最新 4.0.7,session 內經 MCP server 實測);macdoc CLI 0.7.0;macOS 27.0。

Priority: P1

Cross-repo implementation


Current Status

Phase: implemented (upstream verified; awaiting merge/release)
Last updated: 2026-08-31 by idd-verify

Key Decisions

Scope Changes

Blocking

Commits

  • Upstream program 563039c; verified snapshot a3fab8b.
  • Consumer draft cd3e592.

Verification

Pull Requests

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions