Repository navigation
fix(web-fetch): match escaped punctuation in anchors - #255
Conversation
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| prose = content | ||
| for start, end in sorted(markdown_literal_spans(content) + markdown_comment_spans(content), reverse=True): | ||
| prose = prose[:start] + '\ufffc' + prose[end:] | ||
| return _visible(prose, schema) if escape.search(prose) else '' |
There was a problem hiding this comment.
P2: The fallback bypasses mixed-HTML visibility filtering and can accept hidden text. For example, with the body anchor toolbar Edit button, an answer consisting of Intro \!\n\n<script>toolbar \Edit` button</script>reaches this path: it does not start with a block HTML element, sonative_htmlis false. The normal path usesvisible_mixed_html_textviaanchor_textand excludes the script, but this helper masks only Markdown code/comments, and_visible` leaves this embedded script payload in the surface. The literal fallback therefore supplies the missing anchor from hidden script text. Apply the shared mixed-HTML visibility projection before rendering the masked prose (preserving escaped literals), and add a rejection control for hidden HTML following ordinary Markdown prose.
An answer's backslash escape renders to a literal character, while a body anchor is rendered as Markdown and loses the same characters as delimiters. An observed '`Edit`' therefore could not match '\`Edit\`'. Anchors now also compare literally against the answer's escape-rendered prose. Code and hidden comments never supply that surface, and declared plain text keeps its backslashes.
The literal fallback read the raw answer, so with any backslash escape a mixed-HTML answer could supply an anchor from alt, title, aria-label, meta content, hidden spans, scripts or styles. The fallback now runs only when the answer has no HTML prose projection. Adds eight rejection controls and updates the scorer bindings.
a985c04 to
edc9620
Compare
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| from .reference_quality import markdown_comment_spans, markdown_literal_spans | ||
| prose = content | ||
| for start, end in sorted(markdown_literal_spans(content) + markdown_comment_spans(content), reverse=True): | ||
| prose = prose[:start] + '\ufffc' + prose[end:] |
There was a problem hiding this comment.
P2: Masking inline code with U+FFFC creates a word boundary that was not present in the rendered answer. For a body_text contract with the single anchor edit, the answer "Use preedit \!" renders as "Use preedit !" and correctly fails the existing atomic-label check. The new fallback instead compares "Use \ufffcedit !", so _stable_literal_match accepts edit as a complete word. This introduces a false pass even for anchors without escaped punctuation; the unrelated escape enables it. Preserve the original boundary constraints around masked regions (or reject matches that rely on a mask as their word boundary), and add an adjacent-code negative control alongside the existing control for joining phrase words.
The escaped anchor surface masked code with a non-word character, so an anchor could match a word joined to a code span, such as `pre`edit. The mask is now a word letter, and two rejection controls cover both sides.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| from .reference_quality import markdown_comment_spans, markdown_literal_spans | ||
| prose = content | ||
| for start, end in sorted(markdown_literal_spans(content) + markdown_comment_spans(content), reverse=True): | ||
| prose = prose[:start] + '\u01a3' + prose[end:] |
There was a problem hiding this comment.
P2: The lowercase mask can manufacture a camel-case boundary and produce a false pass. For a body_text anchor EDIT, the answer "PEDIT \!" renders as PEDIT !, which the original matcher correctly rejects. This fallback instead produces ƣEDIT !; _stable_literal_match calls separate_case_labels, which splits the lowercase ƣ from uppercase EDIT, so the missing standalone anchor passes. The new joined-word controls only use lowercase edit and do not cover this case. Preserve boundary semantics across masked regions (including case splitting), and add an uppercase joined-word rejection control.
An answer with tag-like text could still supply an anchor from HTML payloads, and the lowercase code mask added a case boundary. The fallback now skips any answer with tag-like text, which replaces the projection guard and comment masking, and the mask is a caseless word letter. Adds two rejection controls and updates the scorer bindings.
There was a problem hiding this comment.
✅ Re-review complete · 7b1dd1f
No findings in this incremental review.
Question
On
dynamic-027-ej2-syncfusion-com-react, why do answers with\`Edit\`fail an anchor containing`Edit`?Cause
The two sides are rendered differently. The answer's escape renders to a literal backtick, but
_stable_literal_matchalso renders the anchor as Markdown, so its backticks become a code span and disappear. The comparison istoolbar `edit` buttonagainsttoolbar edit button. The same happens with escaped*,_and[.This path only runs for
body_textandpage_identityanchors. Other schemas fold both sides through Markdown normalization.Fix
When an anchor misses, compare its literal text against the answer rendered with code spans and code blocks masked out. This only runs if the answer has a backslash escape outside code and contains no tag-like text (
<followed by a letter,/,!or?), so attribute values, hidden elements and comments cannot supply an anchor. The mask is a caseless word letter, so it adds no word or case boundary. It adds no new modules.Evidence
main; all 34 pass on head. Rejects cover the wrong word, missing text, code spans, fences, indented code, comments, link destinations, declared plain text, words joined to code spans, case boundaries next to code spans, and mixed HTML (alt,title,aria-label,<meta content>,<span hidden>,<script>,<style>). The 8 original mixed-HTML controls fail if the HTML skip is removed.code-migration.jsonandtests/golden/web-fetch.jsonupdated. The golden changes are hash-only.tests/test_scoring_regressions.py,tests/benchmarks/test_current_scoring_controls.py,tests/test_golden_reports.pyandmake lint-checkpass.chromiumlightpandamoli-fixedmoli-pr919required_facts_missingboth remainobscurarequired_facts_missingkitesurfThe table is from the 6-row rerun on the current head. The 100 random rows ran only on the first revision and were not rerun; later revisions only narrow the fallback. They produced no verdict or error changes, except that
obscura__dynamic-058-zh-stable-tdesign-table__r001timed out on both sides and was not compared. The first run produced no verdicts because of a bug in my throwaway script, so it was fixed and rerun.In the 430-task dataset bound to this evidence, 6,223 anchor alternatives exist across all schemas, and 4,058 of them (in 276 tasks) are
body_textand can reach the fallback. One renders differently from its literal text under the check I ran, the anchor on this task. That does not bound the fix: the fallback runs for any missed anchor on those paths, and other datasets were not counted.Limits and what I did not do
moli-pr919keeps its anchor error. This can't create a false pass.`Edit`also matches a literal backtick anchor. This is the one way matching goes beyond backslash escapes; those characters still render identically.moli-pr919andobscuramiss required facts, and did not check whether fact matching has a similar gap.