Skip to content

fix(doclang): sanitize XML-illegal text characters#687

Open
AkhilTrivediX wants to merge 1 commit into
docling-project:mainfrom
AkhilTrivediX:codex/sanitize-doclang-xml-text
Open

fix(doclang): sanitize XML-illegal text characters#687
AkhilTrivediX wants to merge 1 commit into
docling-project:mainfrom
AkhilTrivediX:codex/sanitize-doclang-xml-text

Conversation

@AkhilTrivediX

Copy link
Copy Markdown

Summary

Preserves XML-illegal text characters as visible Unicode markers during DocLang serialization, preventing parseString from raising on content such as PPTX soft line breaks (\x0b).

Fixes #686

Changes

  • Normalize XML 1.0-illegal characters in the shared DocLang text-escaping path.
  • Represent each removed control character as [U+XXXX] so the source anomaly remains visible.
  • Add regression coverage for compact and pretty-printed output.

Type of change

  • Bug fix

How Has This Been Tested?

  • uv run pytest test/test_serialization_doclang.py -k xml_illegal -q
  • uv run mypy docling_core/transforms/serializer/doclang.py test/test_serialization_doclang.py
  • uv run ruff check docling_core/transforms/serializer/doclang.py test/test_serialization_doclang.py
  • uv run ruff format --check docling_core/transforms/serializer/doclang.py test/test_serialization_doclang.py

Checklist

  • I added regression coverage for the reported failure.
  • The focused checks above pass locally.

Signed-off-by: AkhilTrivediX <118957648+AkhilTrivediX@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @AkhilTrivediX, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

DocLangDocSerializer raises uncaught ValueError on XML-illegal characters (e.g. \x0b from PPTX soft line-breaks)

1 participant