Skip to content

Read Backslash Escapes in a Definition's Label and Angle Destination - #3637

Merged
ptr727 merged 2 commits into
developfrom
3426-escaped-destinations
Oct 30, 2026
Merged

ptr727 merged 2 commits into
developfrom
3426-escaped-destinations

Conversation

@ptr727

@ptr727 ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the finding Copilot raised on promotion #3636 against #3635's spec/fidelity_text.py _DESTINATION, and the second one its review body named. Both come from one root cause: the regex re-reading a definition's as-written destination did not honor backslash escapes.

  • An angle-bracket destination holding an escaped > was cut at it, so [b]: <https://example.test/a\>b> read as https://example.test/a\.
  • A label ending in an escaped backslash matched nothing, so [a\\]: one.md raised AttributeError in link_definitions.

The regex now anchors on the label's opening [ and honors escapes on both sides, including a label the parser lets wrap after a backslash. test_an_escape_in_a_label_or_an_angle_destination_is_read_through pins all three shapes. The first two fail on the old regex, and the third on this branch's first commit.

Verification

Dropped findings

  • spec/fidelity_text.py _DESTINATION, pre-existing: [ \t>]* swallows a leading > of a bare destination, an angle destination holding a backslash-newline falls back to \S+, and \S+ stops at a non-breaking space the parser keeps. The old regex behaved the same on each, and none is a realistic README shape.

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 29, 2026 20:17
_DESTINATION anchors on the label's opening bracket and honors escapes
on both sides, so a label ending in an escaped backslash is found and an
angle-bracket destination holding an escaped '>' is read whole rather
than cut at it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A label's escape may take the line break the parser lets a label wrap
on, so such a definition matches as it did before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 30, 2026 03:27
@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 149f8835ce6c90a64832f8e398809afc22c22b03, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The supplied review status indicates that no active issues remain, supporting approval progression.

No open issues 🎉

What changed in this PR

This pull request improves raw Markdown definition parsing so escaped characters in labels and angle-bracket destinations are read correctly, preventing truncated destinations and missing definitions.

Changes:

  • Updates _DESTINATION to honor escapes in labels and angle destinations, including labels wrapped after a backslash.
  • Adds regression tests for escaped backslashes, escaped angle brackets, and wrapped labels.
  • Preserves the parser’s as-written destination behavior for downstream audits.

A review finding remains in spec/fidelity_text.py: balanced brackets inside valid definition labels are still rejected, which can cause link_definitions to crash.

File Summary
tests/​test_fidelity_text.py Adds regression coverage for escaped definition labels, escaped angle-bracket destinations, and wrapped labels.
spec/​fidelity_text.py Expands definition-destination extraction to honor escaped characters; balanced brackets inside labels still require handling.

Review effort: Lite

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.69%. Comparing base (04bd8ae) to head (149f883).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3637   +/-   ##
========================================
  Coverage    81.69%   81.69%           
========================================
  Files           26       26           
  Lines         9111     9111           
========================================
  Hits          7443     7443           
  Misses        1668     1668           
Flag Coverage Δ
python-3.13 81.69% <100.00%> (ø)

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.

@ptr727
ptr727 merged commit 19548f4 into develop Oct 30, 2026
14 checks passed
@ptr727
ptr727 deleted the 3426-escaped-destinations branch October 30, 2026 03:40
ptr727 added a commit that referenced this pull request Oct 30, 2026
…nitions Through markdown-it-py (#3636)

Promotes the #3426 markdown-it-py link reading from `develop` to `main`.

- [#3635](#3635) Reads
`spec/validate.py`'s link targets, sections, and headings, and the
README audit's reference definitions, through `spec/fidelity_text.py`
and markdown-it-py. A definition resolves first-wins with folded lookup,
as GitHub renders it, and code is content rather than links. The
validator now runs under `uv run --no-project --script`.
- [#3637](#3637) Reads
backslash escapes in a definition's label and angle destination, so an
escaped `>` no longer cuts a destination short and a label ending in an
escaped backslash no longer raises. It answers both findings Copilot
raised on this promotion.

Closes #3426

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants