Skip to content

Resolve workbook relationship namespace prefixes - #367

Merged
MathNya merged 1 commit into
MathNya:masterfrom
colin-kiegel:fix/workbook-relationship-namespaces
Sep 14, 2026
Merged

MathNya merged 1 commit into
MathNya:masterfrom
colin-kiegel:fix/workbook-relationship-namespaces

Conversation

@colin-kiegel

@colin-kiegel colin-kiegel commented Sep 12, 2026

Copy link
Copy Markdown

Summary

Fixes #366.

Resolve workbook relationship elements by the package-relationships namespace URI and the local name Relationship, rather than matching the raw XML spelling. This allows arbitrary namespace prefixes such as ns0: and pkg: without accepting same-named elements from unrelated namespaces.

The production change is confined to src/reader/xlsx/workbook_rels.rs; it uses the existing quick-xml dependency's NsReader. Attribute reading, target normalization and pivot-cache handling remain unchanged. No dependencies or public APIs change.

Regression coverage

  • Default namespace and two arbitrary prefixes.
  • Foreign namespaces, an explicitly empty namespace and unrelated element names are not interpreted as package relationships.
  • Namespace declarations and prefix rebinding on individual child elements are resolved in scope.
  • Three synthetic workbooks, generated in memory by the existing writer, preserve text, numeric cells, a bold font and a thin border during read and write/reopen. The variants differ only in the workbook-relationships XML prefix spelling; no binary fixtures or customer data are included.

On the unchanged upstream base (4195480ede258a27eebdd202ede0e4457aff8822, version 3.1.1), the default-namespace integration case passes and both prefixed cases fail with an empty A1 instead of the expected text. All three pass with this patch.

Verification

  • cargo test --locked --offline: passes (340 tests, including 79 doctests; 23 existing ignored tests).
  • cargo clippy --locked --offline -- -D warnings: passes (the upstream CI command).
  • cargo clippy --locked --offline --test workbook_relationship_namespaces -- -D warnings: passes.
  • cargo +nightly-2026-09-11 fmt --all --check: passes.
  • git diff --check: passes.

An additional cargo clippy --locked --offline --all-targets --all-features -- -D warnings run reports five existing test-code findings: four float_cmp findings in src/helper/color.rs and one uninlined_format_args finding in src/structs/pivot_table_definition.rs. The same five findings reproduce on the unchanged upstream base with the same toolchain and lockfile; they are not changed by this PR.

Tests and clippy run with Rust 1.98.1 in a disposable, non-root, network-isolated container. Formatting uses a date-pinned nightly to honor the repository's rustfmt configuration. The generated local lockfile is not committed, consistent with the repository policy.

Scope and disclosure

This is an AI-assisted fix and test implementation (gpt-6-astra high). The reproducer is fully synthetic.

This PR deliberately preserves the reader's existing self-closing-element handling; paired start/end relationship tags, other package XML readers and XML encoding support are outside this prefix-resolution fix.

@MathNya

MathNya commented Sep 14, 2026

Copy link
Copy Markdown
Owner

@colin-kiegel
Thank you for the PR.
To be honest, I hadn't really given much thought to namespaces.
I think the source code you revised is an ideal approach to solving the problem.
I'll go ahead and merge it.

@MathNya
MathNya merged commit 35bbffa into MathNya:master Sep 14, 2026
5 checks passed
@colin-kiegel
colin-kiegel deleted the fix/workbook-relationship-namespaces branch September 14, 2026 14:58
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.

Valid prefixed workbook relationships silently produce empty worksheets on read (3.1.0)

2 participants