AntFleet

Disagreement · 2385fc2f-openai-0

Misleading test name/comment: escapeXml will double-escape already-escaped entities, but test claims otherwise

mismatch
repo e24ef98c·PR #4·reviewed 2 weeks ago

Primary finding

Misleading test name/comment: escapeXml will double-escape already-escaped entities, but test claims otherwise

mediumtest-gaphigh
  • apps/web/lib/rss.test.ts:9-12
  • apps/web/lib/rss.ts:14-16
The escapeXml implementation replaces all occurrences of &, <, >, ", ' in one pass. If given a pre-escaped entity like "&amp;", it will still replace the leading '&' producing "&amp;amp;". The test titled "does not double-escape pre-escaped entities" neither uses pre-escaped input nor verifies idempotence, and its comment about replacement order is inaccurate for a single-pass regex replace. This can mask future assumptions that escapeXml is idempotent.

Recommendation

Decide and document the contract: if callers always pass raw, unescaped text, rename the test (e.g., "escapes '&' before '<' without creating new escapable characters") and add a test clarifying that pre-escaped strings may be double-escaped. If idempotence on already-escaped entities is desired, update escapeXml to avoid escaping ampersands that already start a valid entity (e.g., use /&(?![a-zA-Z]+;|#\d+;|#x[0-9a-fA-F]+;)|[<>"']/g) and add a test asserting escapeXml("&amp;") === "&amp;".

Counterpart finding

escapeXml regex misses the apostrophe entry in XML_ESCAPES map mapping but regex character class is correct — verify ordering

lowbuglow
  • apps/web/lib/rss.ts:14-16
Regex character class [&<>"'] correctly matches all five characters and the map has entries for all five. Tests confirm behavior. No actual bug — confidence low; leaving as a note rather than a finding.

Recommendation

None; verified correct.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →