Skip to content

Fix multiple converter bugs: RSS crash, PPTX text loss, CSV pipes, Wikipedia regex, ExifTool encoding - #1723

Closed
Qiaochu Hu (hobostay) wants to merge 1 commit into
microsoft:mainfrom
hobostay:fix/multiple-converter-bugs
Closed

Qiaochu Hu (hobostay) wants to merge 1 commit into
microsoft:mainfrom
hobostay:fix/multiple-converter-bugs

Conversation

@hobostay

Copy link
Copy Markdown

Summary

This PR fixes 5 bugs found across multiple converters:

  1. RSS converter crash (_rss_converter.py): NameError when an RSS feed has no <title> element in <channel>. md_text was never initialized before the conditional assignment, causing a crash when channel_title is None. Fixed by initializing md_text = "" and using += consistently.

  2. PPTX text frame loss (_pptx_converter.py): elif shape.has_text_frame after if shape.has_chart caused text content to be silently dropped for shapes that have both a chart and a text frame. Changed elif to if so both chart and text content are extracted.

  3. CSV malformed tables (_csv_converter.py): Pipe characters (|) in CSV cell values were not escaped, producing broken markdown tables with extra columns. Added escape_pipe() helper to escape | as \|.

  4. Wikipedia language subdomain regex (_wikipedia_converter.py): The regex [a-zA-Z]{2,3} rejected valid Wikipedia subdomains with hyphenated or multi-character language codes (e.g., be-tarask, zh-classical, roa-rup, map-bms). Changed to [a-zA-Z0-9-]+ to match all valid Wikipedia language subdomains.

  5. ExifTool encoding (_exiftool.py): Used locale.getpreferredencoding(False) to decode ExifTool JSON output, which can fail on non-UTF-8 systems (e.g., Windows with cp1252). Since ExifTool always outputs UTF-8 JSON, hardcoded "utf-8" and removed unused locale import.

Test plan

  • All 159 existing test vectors pass
  • 7 new tests added in test_bug_fixes.py covering:
    • RSS feed with no channel title
    • RSS feed with no title or description
    • CSV with pipe characters in cells
    • Wikipedia standard subdomains (en)
    • Wikipedia hyphenated subdomains (be-tarask)
    • Wikipedia multi-character subdomains (zh-classical)
    • Wikipedia numeric subdomains (roa-rup)
  • Total: 203 tests passed, 0 failures

🤖 Generated with Claude Code

…kipedia regex, ExifTool encoding

1. RSS: Initialize md_text before conditional to prevent NameError when
   channel has no title element
2. PPTX: Change elif to if for text frame extraction so shapes with both
   charts and text frames don't silently lose text content
3. CSV: Escape pipe characters in cell values to prevent malformed
   markdown tables
4. Wikipedia: Expand language subdomain regex to support hyphenated and
   multi-character codes (e.g., be-tarask, zh-classical, roa-rup)
5. ExifTool: Hardcode UTF-8 decoding since ExifTool always outputs
   UTF-8 JSON regardless of system locale

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@afourney

Copy link
Copy Markdown
Member

Thanks for the contribution.

These look like legitimate fixed, but should be separated into separate focused PRs. Please also check the current main brain to verify the issues are still present. A number of them may have already been corrected in other PRs.

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.

2 participants