Skip to content

fix: literal escapes decoded twice (N-Triples) and xml:lang leaking from empty elements (RDF/XML) - #224

Merged
kiivihal merged 2 commits into
mainfrom
fix/literal-unescape-and-xml-lang
Nov 22, 2026
Merged

kiivihal merged 2 commits into
mainfrom
fix/literal-unescape-and-xml-lang

Conversation

@kiivihal

Copy link
Copy Markdown
Member

What

Two parser bugs that change indexed literals. Each one has a conformance case and a FINDINGS row.

N-Triples: escapes decoded twice (F29, case 0008). gon3 ran its UCHAR pass, which already turns \\ into \, and then replaced ECHARs with sequential ReplaceAll calls. An escaped backslash therefore formed a new escape with the next character: "C:\\temp" was indexed as C:<TAB>emp, and "a\\n" as a real newline. Fixed in gon3 (9cf4a2d, one-pass unescape); this PR bumps go.mod to it.

RDF/XML: xml:lang leaking from an empty property element (F28, case 0109). The empty-element branch emitted the literal without clearing the property element's language, unlike the non-empty path. So <schema:description xml:lang="nl"></schema:description> gave the next sibling literal, or every literal of the next nested node, the language nl. On one museum dataset that was 139 literals. The fix is one line. nave.golden.nt had the leak baked in (dcterms:created "1947-1958"@nl after an empty dc:title xml:lang="nl") and is corrected.

Testing

  • TestParseXMLLangInheritance: two new cases (sibling property, next nested node). Both failed before the fix.
  • TestConformance/0109 and TestConformance/0008 fail without their fix and pass with it.
  • go test ./ikuzo/rdf/... ./ikuzo/service/x/bulk/: pass. The suites that need a Docker socket (elasticsearchtests, service/x/index, hub3/fragments) were not run locally.

The empty-element branch emitted the literal without clearing the
property element's language, unlike the non-empty path. The next sibling
literal, or every literal of the next nested node, inherited it.

Two cases in TestParseXMLLangInheritance and conformance case 0109
(F28). nave.golden.nt had the leak baked in: dcterms:created followed an
empty dc:title xml:lang="nl" and came out "1947-1958"@nl.
gon3 decoded an escaped backslash twice, so it formed a new escape with
the character after it: "C:\\temp" was indexed as C:<TAB>emp and "a\\n"
as a real newline. Bump gon3 to 9cf4a2d, which decodes UCHARs and ECHARs
in a single pass.

Conformance case 0008 (F29) covers escaped backslashes before n and t,
a double escaped backslash, an escaped quote and \u005C.
@kiivihal
kiivihal merged commit 58f3a62 into main Nov 22, 2026
6 checks passed
@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.95%. Comparing base (9ea9463) to head (6ee4bde).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #224   +/-   ##
=======================================
  Coverage   36.95%   36.95%           
=======================================
  Files         414      414           
  Lines       38326    38327    +1     
=======================================
+ Hits        14164    14165    +1     
  Misses      24160    24160           
  Partials        2        2           
Flag Coverage Δ
unittests 36.95% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant