Skip to content

fix(catalog): a <...> URL keeps its pipe and a destination its spaces; pin the bracket counter - #752

Open
antonwolfy wants to merge 4 commits into
intel:mainfrom
antonwolfy:fix/url-extraction-delimited
Open

antonwolfy wants to merge 4 commits into
intel:mainfrom
antonwolfy:fix/url-extraction-delimited

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the review of #459, where two points were left open: a delimited URL is cut at | and at a space, and no test pins the bracket counter (T11.2, T13.2).

On main, extract_urls("<https://acme.dev/a|b>") gives ['https://acme.dev/a'] and extract_urls("[a](<https://acme.dev/x y>)") gives ['https://acme.dev/x'], although the punctuation of an autolink or a <...> destination is part of the URL, and the probe requests the wrong page. Replacing brackets -= 1 with pass in _clean_url passes the whole suite.

Changes

  • dokimi/dokimi/external/online_checks.py: in _clean_url, a delimited URL (an autolink or a <...> destination) ends at its > only, so a | inside it stays. The undelimited case still ends at |.
  • Table rows: a GFM table splits its row at an unescaped | before it reads links, and extraction sees the row as one text. A line that starts with | is therefore passed as table_row, and there an unescaped pipe still ends a delimited URL (| <https://acme.dev/a|b> | x | gives https://acme.dev/a). A table without a leading pipe is not detected.
  • _distinct_urls reads a <...> link destination up to its >, blanks included (a trailing one too); [a](<https://acme.dev/x y>) is requested as https://acme.dev/x%20y (httpx encodes the space). An autolink holds no space under CommonMark and is unchanged. A backslash-escaped > or < (any backslash escape of ASCII punctuation) does not end or stop the scan: [a](<https://acme.dev/x y\>z>) is requested as https://acme.dev/x%20y%3Ez.
  • Tests in dokimi/tests/test_catalog_online.py: the pipe in an autolink and in a destination, the table-row cases, the spaced destination with a mocked transport that sees /x%20y only, and [see https://acme.dev/a[b]c] for more, which pins brackets -= 1.
  • Changelog fragment (Fixed).

Risk

A URL in <...> that holds a |, or a <...> destination that holds a space or an unmatched )/], is now probed whole instead of cut. A skill that has such a link gets its real target checked, so a link-dead can appear or go. Nothing else changes: the docs do not say where a URL ends, so none changed.

Testing

On a Linux review host, at 213e757 (on main b4bcfa4):

  • make ci-local: 33 passed, 0 failed, 14 skipped (job conditions, no semgrep or micromamba, other-Python legs). 20402 tests passed, 19 skipped; the coverage of changed lines step passed.
  • Repro: main prints ['https://acme.dev/a'] ['https://acme.dev/x']; this branch gives ['https://acme.dev/a|b'] ['https://acme.dev/x y'].
  • The new tests on main's code: the pipe test and the spaced-destination test fail.
  • Mutants, each failing the test that pins it: brackets -= 1 → pass fails test_an_unbalanced_closing_bracket_ends_the_url_after_a_balanced_pair; dropping table_row from the pipe condition fails test_a_pipe_in_an_angle_delimited_url_is_part_of_it_outside_a_table_row; not reading the angle destination to its > fails test_an_angle_destination_keeps_its_spaces_and_is_probed_with_the_path_encoded. The bracket test passes on main: it pins behaviour that already held.
  • A trailing blank inside <...> is kept: extract_urls("[a](<https://acme.dev/x >)") gives ['https://acme.dev/x '] and the probe requests /x%20; with .rstrip() restored the spaced-destination test fails. An unclosed [a](<https://acme.dev/x y) falls back to the bare URL https://acme.dev/x, which covers the branch codecov reported as partial.
  • An escaped bracket in a <...> destination: extract_urls gives ['https://acme.dev/x y>z'] for [a](<https://acme.dev/x y\>z>) and ['https://acme.dev/x y<z'] for the \< form, and the mocked transport sees /x%20y%3Ez only. With the previous scan the same test fails (/x y\ was read).
  • Not run: Python 3.11, 3.12 and 3.14 (the host runs one version); semgrep.

Revert

A plain revert restores the cut at | and at a space. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…; pin the bracket counter

Settles two review points of intel#459 (T11.2 and T13.2).

The end-of-URL scan cut every URL at a `|`, so `<https://acme.dev/a|b>` was probed as `https://acme.dev/a`. A delimited URL (an autolink or a `<...>` destination) now ends at its `>` only; the undelimited case still ends at a pipe. In a table row (a line that starts with `|`) an unescaped pipe still ends the URL, because a GFM table splits its row at it before it reads links.

A `<...>` destination may hold spaces under CommonMark: `[a](<https://acme.dev/x y>)` was cut at the space and `/x` was probed. It is now read up to its `>` and httpx requests `/x%20y`. An autolink holds no space and is unchanged.

Tests pin both and the table-row choice, and `[see https://acme.dev/a[b]c] for more` kills the mutant that drops `brackets -= 1`.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner November 14, 2026 13:48
@exai-bot

exai-bot commented Nov 14, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

CI at 7777982: 25 passing, 3 skipped.

Review details
  • Commit reviewed: 7777982 against merge base 213e757
  • Coverage: 2 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 50k tokens (29k from cache), 16s
  • Tool calls: 4 (3 file_read, 1 local_check_results)
  • small change set: 2 files

Comment thread dokimi/dokimi/external/online_checks.py Resolved
@codecov-commenter

codecov-commenter commented Nov 14, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.72%. Comparing base (b4bcfa4) to head (7777982).
⚠️ Report is 8 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #752   +/-   ##
=======================================
  Coverage   95.71%   95.72%           
=======================================
  Files         414      415    +1     
  Lines       55310    55369   +59     
  Branches     9509     9518    +9     
=======================================
+ Hits        52941    53000   +59     
  Misses       1466     1466           
  Partials      903      903           
Files with missing lines Coverage Δ
dokimi/dokimi/external/online_checks.py 96.36% <100.00%> (+0.05%) ⬆️

... and 7 files with indirect coverage changes

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

@antonwolfy antonwolfy self-assigned this Nov 14, 2026
Settles the review point that `.rstrip()` cut the trailing space of `[a](<https://acme.dev/x >)`, so `/x` was probed instead of `/x%20`. The destination is now taken up to its `>` as written. Tests cover the extraction, the request, and the unclosed `<` fallback branch that codecov reported as partial.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
Comment thread dokimi/dokimi/external/online_checks.py Resolved
antonwolfy and others added 2 commits November 14, 2026 20:04
… destination

Review point 4575431969: the scan for a "<...>" destination stopped at any ">" and refused any "<", so "[a](<https://acme.dev/x y\>z>)" was probed as "/x y\" instead of "/x%20y%3Ez", and an escaped "<" left the destination unscanned.

The scan now reads a backslash escape of ASCII punctuation as one unit, keeping the original text so that _clean_url decodes it. The test covers extraction of both escapes and the request the transport sees.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
`[a](<https://acme.dev/x\<z>)` extracted nothing: the template guard saw
the `<` after the match before the angle scan ran. The guard now runs after
the scan and ignores a destination the scan closed at its `>`.

Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
@vchamarthi

Copy link
Copy Markdown
Contributor

Pushed 1 commit to fix/url-extraction-delimited (213e757..7777982).

  • The template guard no longer skips a <...> destination that the angle scan closed at its >.
    Run: the full suite with main merged in, 20489 passed.

This branch has not been deployed

No deployments
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.

4 participants