Skip to content

#560: route object names through eo:escape in defect messages#860

Merged
yegor256 merged 2 commits into
objectionary:masterfrom
bibonix:fix-560-escape-object-names
May 13, 2026
Merged

#560: route object names through eo:escape in defect messages#860
yegor256 merged 2 commits into
objectionary:masterfrom
bibonix:fix-560-escape-object-names

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented May 4, 2026

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 @name instead of going through eo:escape(...):

  • src/main/resources/org/eolang/lints/critical/pos-without-line.xsl:28 — printed the bare @name with 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 @name in literal " characters but did not call eo: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 as Object "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 form name='foo"bar':

  • pos-without-line/escapes-name-in-defect-message.yaml
  • duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml

Both 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 parameterized LtByXslTest.testsAllLintsByEo, which runs all 359 single-pack assertions; locally that test reports Tests run: 359, Failures: 0, Errors: 0, Skipped: 1 after this change.

CI status

The mvn (×3 OS), deep, and reserved jobs fail on this branch. They are pre-existing failures that have been red on master since 2026-04-25 (commit 820cb36b, the qulice 0.27.1 bump): master's mvn install times out in PkByXslTest.doesNotDuplicateDefectsWhenMultipleDefectsOnTheSameLine after 45s. I reproduced the same failure by running mvn clean install -ntp -PskipITs --errors --batch-mode against master locally 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.

bibonix added 2 commits May 4, 2026 05:09
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.
@yegor256 yegor256 marked this pull request as ready for review May 13, 2026 12:47
Copilot AI review requested due to automatic review settings May 13, 2026 12:47
@yegor256 yegor256 merged commit b2f20a9 into objectionary:master May 13, 2026
16 of 21 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-line and duplicate-names-in-diff-context lints to render object names using eo: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>
@0crat
Copy link
Copy Markdown

0crat commented May 13, 2026

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all object names should be escaped

4 participants