Repository navigation
Read documents that have no relationships part - #196
Merged
Merged
Conversation
load_rels already rescues a missing word/_rels/document*.xml.rels and leaves @RELS nil, but hyperlink_relationships then called @rels.xpath, so #hyperlinks, and with it #paragraphs/#tables/#to_s, raised NoMethodError. Return an empty NodeSet instead, so #hyperlinks is {}. Add a fixture_without spec helper that drops zip entries from a fixture in memory, so such documents need no extra binary fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Document#load_relsalready rescues a missingword/_rels/document*.xml.relsand leaves@relsnil. But#hyperlink_relationshipsthen called@rels.xpathwithout a nil check. So#hyperlinks, and with it#document_properties,#paragraphs,#tables,#to_sand#to_html, raisedNoMethodErrorfor such documents.Fix
When
@relsis nil,#hyperlink_relationshipsreturns an emptyNodeSet, so#hyperlinksreturns{}and the document reads normally. This mirrors the missing-styles.xmlhandling from #158.Tests
fixture_without(name, *entries)spec helper: rebuilds a fixture in memory with the given zip entries dropped, so this needs no new binary fixture.spec/docx/document_spec.rbonbasic.docxwithout its rels part:#hyperlinksis{}, and paragraphs / html are still read.Closes #192
🤖 Generated with Claude Code