objectionary / objectionary/lints

`DfContext` HTML entity decoding is incomplete and introduces platform-specific inconsistencies

Open Beginner friendly
#1,386 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good-title
Dominant language
Java
Stars
14
Forks
39
Avg merge
22h 54m
Merged PRs (30d)
90

Description

Problem

DfContext (which decodes HTML entities in defect @context) decodes incompletely and platform-dependently, so contexts can contain literal </" remnants and differ between operating systems.

Root cause

src/main/java/org/eolang/lints/DfContext.java:60-64:

this.context = defect.context()
    .replace("
", System.lineSeparator())
    .replace(""", "\"")
    .replace("&", "&");
  1. &amp; is replaced last, so double-encoded input like &amp;lt; becomes &lt; (still encoded) instead of <.
  2. The standard entities &quot; and &#39;/&apos; are not handled (only &#34;), so a context using &quot; keeps the literal &quot;.
  3. &#xA; is replaced with System.lineSeparator() (\r\n on Windows, \n on Unix), while XML normalization always means LF — the resulting context differs across OSes and breaks string comparisons.

Minimal example

A context value &amp;lt;o&amp;gt; should decode to <o> but yields &lt;o&gt;; a value &quot;x&quot; keeps &quot;x&quot; verbatim.

Expected behavior

Decode entities in a single normalized pass:

  • replace &amp; first (or loop until stable),
  • handle &quot;, &#39;, &apos;, &#10;/&#xA;,
  • use a fixed \n for line breaks, not System.lineSeparator().

Related

  • src/test/java/org/eolang/lints/DfContextTest.java — only covers the happy path; the double-encoding and entity variants are untested.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/main/java/org/eolang/lints/DfContext.java:60-64 to trace the current entity decoding, then read src/test/java/org/eolang/lints/DfContextTest.java. Add coverage for double-encoded entities, quote and apostrophe variants, and normalized line breaks. Done means these cases decode consistently to the expected context on every operating system.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.