fix(xlsx): escape pipe characters in table cells - #2437
Open
Soroush Ahmadi (soroush5) wants to merge 4 commits into
Open
fix(xlsx): escape pipe characters in table cells#2437Soroush Ahmadi (soroush5) wants to merge 4 commits into
Soroush Ahmadi (soroush5) wants to merge 4 commits into
Conversation
A literal | in a cell value or header is data, not a column separator. Without escaping, converted rows gain phantom columns and the Markdown table is corrupt. Reuses the CSV converter's escaping so Excel tables behave like CSV tables.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The OCR XLSX converter remains affected, and the new XLS test relies on an undeclared dependency.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Escapes Markdown-significant pipes in Excel tables.
Changes:
- Reuses CSV cell escaping for XLSX/XLS values and headers.
- Adds regression tests for pipes and backslashes.
File summaries
| File | Description |
|---|---|
_xlsx_converter.py |
Escapes spreadsheet table cells and headers. |
test_xlsx_tables.py |
Adds XLSX/XLS escaping tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for s in sheets: | ||
| md_content += f"## {s}\n" | ||
| html_content = sheets[s].to_html(index=False) | ||
| html_content = _escape_sheet(sheets[s]).to_html(index=False) |
Comment on lines
+23
to
+24
| def _xls_bytes(rows: list) -> bytes: | ||
| import xlwt |
Member
There was a problem hiding this comment.
This test needs to be rewritten to not depend on any new packages.
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.
Fixes #2436.
A
|in an Excel cell or header is data, not a column separator. This reuses the CSV converter's escaping (_escape_table_cell, including backslash handling) for both the XLSX and XLS converters, so Excel tables behave like CSV tables. Non-string values (numbers, dates, NaN) pass through untouched.Tests: new
tests/test_xlsx_tables.py(4 tests, failed before, pass after). Full suite: 534 passed + 160 vector tests, no regressions.black --checkandgit diff --checkclean.