Repository navigation
fix(terminology): keep exported XML well-formed for text with & and < - #1547
Open
borealisalastor-byte wants to merge 1 commit into
Open
borealisalastor-byte wants to merge 1 commit into
borealisalastor-byte wants to merge 1 commit into
Conversation
The terminology and data-training exporters build the document with ElementTree, then restore '<', '>' and '&' to raw characters. A description such as '投入 < 10% & 增长 > 5%' therefore came out as markup that no longer parses, and that string is inserted into a prompt template, so the model received broken structure instead of escaped text. Restore only the quote entities, which cannot break the document, and keep the structural ones escaped.
borealisalastor-byte
force-pushed
the
fix/xml-escape-preserve-structure
branch
from
December 6, 2026 09:12
5222ce3 to
404e810
Compare
This branch has not been deployed
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.
What breaks
to_xml_stringinapps/terminology/curd/terminology.pyandapps/data_training/curd/data_training.pybuilds the document with ElementTree, then restores<,>and&to raw characters. Any terminology description or example SQL containing&,<or>therefore produces markup that no longer parses:That string is inserted into the prompt template, so the model receives broken structure rather than escaped text — and text containing
<can look like a tag boundary.Change
"and', which cannot break the document; keep the structural entities escaped. Both helpers get the same treatment.backend/tests/test_xml_escaping.pyloads the helpers through AST (like the other isolated tests, no ORM/web stack), then checks that descriptions and example SQL with&/</>parse and round-trip, that quotes are still readable, and that the plain-text shape is unchanged.Verification
python -m pytest tests/test_xml_escaping.py -q: 7 passed.287935a6withExpatError: not well-formed (invalid token)(reproduced by loading the pre-fix function).