Conversation
Both ends of an attribute value went through untouched: `parse_attributes` set the submatch of the regex as the value, so `<item foo="a<b"/>` read as `a<b`, and `if_ixml_element~render` wrote the value raw, so an attribute holding `a<b` or a quote produced a document that is not well-formed. The value now goes through lcl_escape on both ends, the same routines the character data of an element already uses - so what the renderer writes the parser reads back as the same value. Tests: an escaped attribute read back unescaped, the renderer escaping the five characters, and a document that survives parse and render unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKSWLpid4QLV6XWAoPixbb
oblomov-dev
force-pushed
the
claude/nifty-meitner-ema3y8-attribute-unescape
branch
from
September 15, 2026 11:07
e3fe41a to
add23f1
Compare
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 is wrong
An attribute value passes both ends of
cl_ixmluntouched.Reading,
parse_attributessets the submatch of the regex as the value:so
<item foo="a<b"/>reads as the seven charactersa<b, where asystem gives
a<b. The character data of an element is unescaped one methodaway (
lcl_escape=>unescape_value); an attribute never was.Writing,
if_ixml_element~renderconcatenates the value as it is:so an attribute holding
a<brenders asfoo="a<b"and one holding a quoteends the attribute early — the document is not well-formed, and the parser
above reads it back as something else or not at all.
The change
The value goes through
lcl_escapeon both ends, the same routines thecharacter data of an element already uses:
Two lines.
escape_valuewrites all five named entities, the apostropheincluded — inside a double-quoted attribute
'is not the shortest formbut it is correct, and it keeps the routine the one both sides share.
Tests
parse_escaped_attribute—foo="a<b&c"reads asa<b&crender_escaped_attribute— a value of&<>"renders as&<>"attribute_roundtrip— a document with an escaped attribute comes out ofparse and render exactly as it went in
npm testis green:abaplint: 0 issue(s) found, 735 file(s) analyzed, andthe full unit run passes.
Relation to the other ixml PRs
Independent of the character-reference change — that one teaches
unescape_valuethe andAforms. This one is what routes anattribute through
unescape_valueat all, so with both merged a characterreference in an attribute resolves too. Either can go first.