Skip to content

fix(ofd):update cnofd viewer for OFD compatibility - #783

Open
xushenl wants to merge 1 commit into
kekingcn:masterfrom
xushenl:fix/fix-ofd-preview-compatibility
Open

fix(ofd):update cnofd viewer for OFD compatibility#783
xushenl wants to merge 1 commit into
kekingcn:masterfrom
xushenl:fix/fix-ofd-preview-compatibility

Conversation

@xushenl

@xushenl xushenl commented Aug 27, 2026

Copy link
Copy Markdown

问题说明

部分 OFD 文件的签章配置中存在空的 References 节点,例如:

<ofd:References CheckMethod="..."/>

旧版 cnofd 在解析该结构时,会直接遍历不存在的 Reference 子节点,导致预览失败并出现以下异常:

TypeError: Cannot read properties of undefined (reading 'forEach')

修改内容

更新 cnofd.umd.min.js 至上游兼容版本,使解析器能够正确处理不包含 Reference 子节点的签章 References 节点。

本次修改仅涉及:

server/src/main/resources/static/ofd/js/cnofd.umd.min.js

不涉及服务端接口、配置和其他预览逻辑。

问题复现:

  1. 准备一份可正常预览的ofd文档,确保通过预览能正常打开。
  2. 使用解压软件打开该文档。
  3. 编辑Doc_0/Signs/Sign_0/Signature.xml文件。
  4. 插入<ofd:References CheckMethod="test"/>
<?xml version="1.0" encoding="utf-8"?>
<ofd:Signature xmlns:ofd="http://www.ofdspec.org/2016">
    <ofd:SignedInfo>
        <ofd:Provider ProviderName="gomain_eseal" Version="2.0" Company="gomain"></ofd:Provider>
        <ofd:SignatureMethod>1.2.156.10197.1.501</ofd:SignatureMethod>
        <ofd:SignatureDateTime>20250104070442.436Z</ofd:SignatureDateTime>
        <!-- test -->
        <ofd:References CheckMethod="test"/>
        <!-- test -->
        <ofd:References CheckMethod="1.2.156.10197.1.401">
            <ofd:Reference FileRef="/Doc_0/Document.xml">
  1. 重新预览,复现问题。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant