Skip to content

Fix MinerU table option sanitization - #16118

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-mineru-options
Jun 17, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-mineru-options

Conversation

@wangq8

@wangq8 wangq8 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Follow on issue: #14831 and PR: #14920 to fix the table options, with table recognition enabled, do not sanitize html tags.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9547bd77-b6b0-43a9-b155-2b7fa0ecd687

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wangq8 wangq8 added the ci Continue Integration label Jun 17, 2026
@wangq8
wangq8 requested a review from buua436 June 17, 2026 03:26
@wangq8
wangq8 marked this pull request as ready for review June 17, 2026 03:26
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 694-695: The condition `if not table_enable:` incorrectly bypasses
`_sanitize_section_text` for all block types instead of just tables, because
`table_enable` is true by default. Replace this condition with a check that
specifically verifies whether the current section is a TABLE block type before
skipping sanitization. This ensures non-table blocks (text, code, lists, images)
are properly sanitized while preserving raw HTML only for TABLE sections.
Additionally, add a logging statement in this branch to document when
sanitization is bypassed, following the coding guideline to log new flows.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad037d6d-6bec-488e-8ff7-4abcfa436f5c

📥 Commits

Reviewing files that changed from the base of the PR and between 5de00bd and 59bffb0.

📒 Files selected for processing (1)
  • deepdoc/parser/mineru_parser.py

Comment on lines +694 to +695
if not table_enable:
section = self._sanitize_section_text(section)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Scope the sanitizer bypass to table blocks.

table_enable is true by default, so this skips _sanitize_section_text for every block type, not just tables. Non-table text/code/list/image chunks can now retain tag noise, and empty image captions like "\n" can be appended instead of stripped/skipped. Preserve raw HTML only for TABLE sections and log that new branch.

🐛 Proposed fix
-            if not table_enable:
+            preserve_table_html = table_enable and output.get("type") == MinerUContentType.TABLE
+            if preserve_table_html:
+                self.logger.debug("[MinerU] Preserve table HTML section without sanitization.")
+            else:
                 section = self._sanitize_section_text(section)
-            if not section:
+            if not section.strip():
                 self.logger.debug("[MinerU] Skip section after sanitization: type=%s", output.get("type"))
                 continue

As per coding guidelines, "**/*.py: Add logging for new flows." This also keeps the behavior scoped to the PR objective of preserving HTML during table processing.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@deepdoc/parser/mineru_parser.py` around lines 694 - 695, The condition `if
not table_enable:` incorrectly bypasses `_sanitize_section_text` for all block
types instead of just tables, because `table_enable` is true by default. Replace
this condition with a check that specifically verifies whether the current
section is a TABLE block type before skipping sanitization. This ensures
non-table blocks (text, code, lists, images) are properly sanitized while
preserving raw HTML only for TABLE sections. Additionally, add a logging
statement in this branch to document when sanitization is bypassed, following
the coding guideline to log new flows.

Source: Coding guidelines

@xuhaiL

xuhaiL commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

good.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (6865039) to head (59bffb0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16118      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants