Repository navigation
Conversation
lxml unescapes attribute values when parsing, but SPEC-OBJECT, SPEC-RELATION, RELATION-GROUP, SPEC-HIERARCHY and some DATATYPE elements wrote DESC/LONG-NAME back without escaping. A value containing &, < or " produced XML that the parser itself rejects. Escape them with lxml_escape_for_html, as SPECIFICATION and the other elements already do. Reported in strictdoc-project/strictdoc#3266. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
stanislaw
approved these changes
Nov 19, 2026
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.
Fixes strictdoc-project/strictdoc#3266
lxml unescapes attribute values when it parses a ReqIF file, so
DESCandLONG-NAMEare stored as plain text (A & B). Mostunparsemethods escape them again withlxml_escape_for_html, but these did not:SPEC-OBJECT:DESCandLONG-NAME(the case in the issue)SPEC-RELATION:DESC(LONG-NAMEusedhtml.escapealready)RELATION-GROUP:DESCandLONG-NAMESPEC-HIERARCHY:LONG-NAMEDATATYPE-DEFINITION-*:LONG-NAMEin three branches and theDESCof enum valuesA requirement whose title contains
&,<or"was therefore written as XML the parser itself rejects, so a parse/unparse round trip broke the file. All of these now uselxml_escape_for_html, likeSPECIFICATIONand the other elements.Tests:
tests/unit/reqif/parsers/test_attribute_escaping.py: SPEC-OBJECT, SPEC-RELATION and RELATION-GROUP go through a parse, unparse, parse round trip with&,<,>and"in DESC/LONG-NAME, and SPEC-HIERARCHY checks the escaped output. All 4 fail onmainand pass with the fix.main(the same 2 tests fail on both in my environment).ruff checkandruff format --checkare clean.I used Claude to help write and test this change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3