#560: route object names through eo:escape in defect messages#860
Conversation
These two YAML packs exercise the same gap from issue objectionary#560: `pos-without-line` and `duplicate-names-in-diff-context` print object names from `@name` straight into their defect messages without going through `eo:escape(...)`, so a name containing an embedded `"` is rendered as bare text instead of "foo\\x22bar". The packs assert the escaped form (single quote of `\\x22`, the eo:escape encoding of an embedded double-quote) and currently fail on master.
…ages Previously `pos-without-line` printed the bare `@name` and `duplicate-names-in-diff-context` wrapped it in literal `"` characters without converting whitespace or quotes. As of this commit both lints delegate to `eo:escape(@name)`, which adds the surrounding quotes and maps spaces to U+2334 (⌴) and embedded `"` to `\\x22`. For names that are plain identifiers the rendered message is unchanged ("foo" → "foo"), so the existing single-pack assertions still hold.
There was a problem hiding this comment.
Pull request overview
This PR addresses #560 by ensuring object names in lint defect messages are consistently escaped/quoted via eo:escape(...), preventing unescaped quotes/spaces from leaking into rendered messages.
Changes:
- Updated
pos-without-lineandduplicate-names-in-diff-contextlints to render object names usingeo:escape(@name). - Added single-pack YAML tests that validate escaping for names containing
"in XMIR (foo"bar→"foo\x22bar").
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/resources/org/eolang/lints/critical/pos-without-line.xsl | Routes @name through eo:escape(...) when composing the defect message. |
| src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl | Imports escape.xsl and switches message formatting to use eo:escape(@name). |
| src/test/resources/org/eolang/lints/packs/single/pos-without-line/escapes-name-in-defect-message.yaml | New regression test asserting the defect message escapes embedded quotes in @name. |
| src/test/resources/org/eolang/lints/packs/single/duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml | New regression test asserting escaped/quoted name rendering in duplicate-name defects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <xsl:text>Object </xsl:text> | ||
| <xsl:value-of select="@name"/> | ||
| <xsl:value-of select="eo:escape(@name)"/> | ||
| <xsl:text> have the "@pos" attribute, but the "@line" attribute is absent</xsl:text> |
|
@bibonix Thanks for the contribution! You've earned +16 points following our bonus policy - you received the base 16 points for providing reviews, plus additional points for your code contribution size, with appropriate adjustments based on review feedback. Please, keep them coming. Your running score is +278; don't forget to check your Zerocracy account too. |
yegor256, this PR fixes #560 - object names in defect messages now go through
eo:escape(...).What changed
Two single-source lints rendered object names directly from
@nameinstead of going througheo:escape(...):src/main/resources/org/eolang/lints/critical/pos-without-line.xsl:28— printed the bare@namewith no quoting at all (Object foo have the "@pos" attribute, ...).src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl:27— wrapped@namein literal"characters but did not calleo:escape, so spaces were not converted to⌴and embedded"characters were left unescaped.This PR routes both through
eo:escape(@name). For names that are plain lowercase identifiers — every name produced by the EO parser today — the rendered text is byte-identical to before, so the existing single-pack assertions ('Object "hello" has the same name as the objects on the lines 6, 8, 10','Object "s" has the same name as the objects on the lines 11', etc.) still hold. For a name with an embedded"the message now renders asObject "foo\x22bar" ...instead of being dropped on the floor.Tests
Two new YAML packs under
src/test/resources/org/eolang/lints/packs/single/...exercise the escape path with XMIR documents that use the entity-encoded formname='foo"bar':pos-without-line/escapes-name-in-defect-message.yamlduplicate-names-in-diff-context/escapes-name-in-defect-message.yamlBoth fail on master (the rendered text contains the bare
foo"bar, not the escaped"foo\x22bar") and pass with the XSL change applied. They are picked up by the parameterizedLtByXslTest.testsAllLintsByEo, which runs all 359 single-pack assertions; locally that test reportsTests run: 359, Failures: 0, Errors: 0, Skipped: 1after this change.CI status
The
mvn (×3 OS),deep, andreservedjobs fail on this branch. They are pre-existing failures that have been red onmastersince 2026-04-25 (commit820cb36b, the qulice 0.27.1 bump):master'smvn installtimes out inPkByXslTest.doesNotDuplicateDefectsWhenMultipleDefectsOnTheSameLineafter 45s. I reproduced the same failure by runningmvn clean install -ntp -PskipITs --errors --batch-modeagainstmasterlocally with no XSL changes — same timeout, same stack — so the redness is unrelated to this PR. Every fast check on this PR (qulice,xcop,pdd,markdown-lint,yamllint,actionlint,bashate,shellcheck,vale,typos,reuse,ort,copyrights,labeler) is green.