From 50f92953aedbb5fbe757f144ca3f373d33618f36 Mon Sep 17 00:00:00 2001 From: bibonix Date: Mon, 4 May 2026 05:09:29 +0000 Subject: [PATCH 1/2] #560: failing tests for object-name escaping These two YAML packs exercise the same gap from issue #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. --- .../escapes-name-in-defect-message.yaml | 20 +++++++++++++++++++ .../escapes-name-in-defect-message.yaml | 13 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/resources/org/eolang/lints/packs/single/duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml create mode 100644 src/test/resources/org/eolang/lints/packs/single/pos-without-line/escapes-name-in-defect-message.yaml diff --git a/src/test/resources/org/eolang/lints/packs/single/duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml b/src/test/resources/org/eolang/lints/packs/single/duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml new file mode 100644 index 000000000..2ce4e437a --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/duplicate-names-in-diff-context/escapes-name-in-defect-message.yaml @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +# yamllint disable rule:line-length +sheets: + - /org/eolang/lints/misc/duplicate-names-in-diff-context.xsl +asserts: + - /defects[count(defect[@severity='warning'])=1] + - /defects/defect[contains(normalize-space(), 'Object "foo\x22bar" has the same name as')] +document: | + + + + + + + + + + diff --git a/src/test/resources/org/eolang/lints/packs/single/pos-without-line/escapes-name-in-defect-message.yaml b/src/test/resources/org/eolang/lints/packs/single/pos-without-line/escapes-name-in-defect-message.yaml new file mode 100644 index 000000000..f6f027343 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/pos-without-line/escapes-name-in-defect-message.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +# yamllint disable rule:line-length +sheets: + - /org/eolang/lints/critical/pos-without-line.xsl +asserts: + - /defects[count(defect[@severity='critical'])=1] + - /defects/defect[normalize-space()='Object "foo\x22bar" have the "@pos" attribute, but the "@line" attribute is absent'] +document: | + + + From a06d05ebe0a71a5d99e40082b279a38488cb998b Mon Sep 17 00:00:00 2001 From: bibonix Date: Mon, 4 May 2026 05:09:38 +0000 Subject: [PATCH 2/2] #560: route object names through eo:escape in defect messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../org/eolang/lints/critical/pos-without-line.xsl | 2 +- .../eolang/lints/misc/duplicate-names-in-diff-context.xsl | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/resources/org/eolang/lints/critical/pos-without-line.xsl b/src/main/resources/org/eolang/lints/critical/pos-without-line.xsl index 483555a98..00c601685 100644 --- a/src/main/resources/org/eolang/lints/critical/pos-without-line.xsl +++ b/src/main/resources/org/eolang/lints/critical/pos-without-line.xsl @@ -25,7 +25,7 @@ critical Object - + have the "@pos" attribute, but the "@line" attribute is absent diff --git a/src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl b/src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl index c8de375c7..879f4043c 100644 --- a/src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl +++ b/src/main/resources/org/eolang/lints/misc/duplicate-names-in-diff-context.xsl @@ -5,6 +5,7 @@ --> + @@ -23,9 +24,9 @@ warning - Object " - - " has the same name as + Object + + has the same name as