Repository navigation
fix: decode XML entities in wiki structures salvaged by regex - #631
Merged
sng-asyncfunc merged 1 commit intoNov 13, 2026
Merged
Conversation
parse_wiki_structure escapes every bare '&' to '&' before parsing. When strict parsing fails, as it does for a truncated response, the regex fallback returned the raw element text, so a title like "Build & Test" showed up as "Build & Test", and entities the model wrote itself (<, >) were never decoded. Decode the texts the fallback captures, as ElementTree does on the strict path. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
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.
parse_wiki_structure(api/services/wiki/structure.py) escapes every bare&to&before parsing, so that one&does not break strict XML. When strict parsing fails anyway, most often on a response cut off at the output-token limit (the salvage path), the regex fallbacks return the element text as it is in the source. Nothing decodes it, so:Build & Testis shown asBuild & Testin the sidebar and page header,<core>,&) stay encoded in the wiki title, description, page titles and file paths.The strict path does not have this problem because ElementTree decodes entities. The texts captured by
_pages_via_regex,_sections_via_regexand_first_groupnow go throughhtml.unescapeafterstrip(). Two small helpers (_text,_texts) replace the repeated strip-and-filter comprehensions.Test:
test_parse_truncated_response_decodes_entitiesfeeds a truncated structure with a bare&in the wiki, page and section titles and&/</>in the description and a file path. Onmainit fails with'Build & Release Wiki' == 'Build & Release Wiki', and with this change it passes.pytest tests/backendpasses (61 tests).