Skip to content

Stop the OSCOLA name pattern from backtracking on long runs of initials - #329

Open
dknauss wants to merge 2 commits into
mainfrom
claude/project-thread-uhwdwn
Open

dknauss wants to merge 2 commits into
mainfrom
claude/project-thread-uhwdwn

Conversation

@dknauss

@dknauss dknauss commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Requested by Dan · project thread

Fixes #327.

Summary

  • What changed? In src/lib/free-text-oscola.js, GIVEN_FIRST_NAME now caps a dotted run of initials at four: (?:\s?\p{Lu}\.){0,3} instead of *. The docblock explains why. Every real name still reads, including "H. L. A. Hart", "H.L.A. Hart", "HLA Hart", "Jean-Paul Sartre", "Mary O’Brien", and "J. R. R. R. Tolkien".
  • Why? The unbounded run sat inside the repeated given-name group (?:…\s+){1,3}. On a long line of initials, the regex could split them between the two in many ways before the $-anchored family name failed, so backtracking grew about cubically. OSCOLA patterns are tried in every style, so a 2.4 KB pasted line (A. A. A. …, ‘Title’ (2001) 12 LQR 34) froze the editor for about 9 seconds whatever the block's style. This turned up in the independent ReDoS review of Read ABNT and OSCOLA citations pasted as text #320.
  • Release: whether this ships as a 1.23.1 patch or waits for 1.24.0 is Dan's call. This PR doesn't bump any version. The CHANGELOG entry sits under Unreleased.
  • Playground demo: no change. Nothing in the demo is different; the fix only matters for malformed pastes.
  • docs/current-metrics.md: the JS source line count goes up by 5, for the docblock.

Validation

  • npm run lint:js passes for the changed files (eslint and prettier --check)
  • npm run lint:css passes (no CSS changed)
  • npm run lint:i18n passes when source strings or translation docs change (no strings changed)
  • npm run test: the free-text and parser suites pass (460 tests). The full suite runs in CI.
  • npm run build succeeds (CI)
  • Tested in the block editor (not needed: the change is a pure parser regex covered by unit tests)
  • New regression test: 801 initials through parseFreeTextCitation() must finish in under a second. With the old pattern it fails at 9,218 ms; with the fix it takes milliseconds. A second new test pins dotted initials up to four.
  • .github/scripts/verify-metrics.sh passes

Checklist

🤖 Generated with Claude Code

https://claude.ai/code/session_01WPtgA2by7WV5UC9oYaXWwd

…initials

GIVEN_FIRST_NAME let a dotted run of initials repeat without limit inside a
repeated given-name group, so a long line of initials could be split many
ways before the family name failed to match. OSCOLA patterns run for every
style, so a 2.4 KB pasted line held the editor for about 9 seconds. Bound the
run at four initials, which still reads every real name, and add a timing
regression test.

Fixes #327.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2by7WV5UC9oYaXWwd
@dknauss dknauss self-assigned this Nov 30, 2026
The fix ships alone as 1.23.1 from the v1.23.0 tag, so its CHANGELOG entry
moves from Unreleased to a 1.23.1 section, and readme.txt gets the same
changelog line and upgrade notice the patch release carries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WPtgA2by7WV5UC9oYaXWwd
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.34%. Comparing base (97a7538) to head (2d51851).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #329   +/-   ##
=========================================
  Coverage     87.34%   87.34%           
  Complexity       67       67           
=========================================
  Files           115      115           
  Lines         12917    12917           
  Branches       1373     1373           
=========================================
  Hits          11282    11282           
  Misses          489      489           
  Partials       1146     1146           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

Plugin readme preview

Open preview · Commit 2d51851

35 passed · 2 warnings · 0 notes

Warnings

  • The first changelog release is 1.23.1, but Stable tag is 1.23.0.
  • The first changelog release is 1.23.1, but PHP Version is 1.23.0.
Passed checks (35)
  • 145 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPLv2 or later.
  • 5 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Tested up to 7.1, the latest WordPress major release.
  • Stable tag is declared: 1.23.0.
  • The PHP Version header is declared: 1.23.0.
  • Stable tag matches the PHP Version header: 1.23.0.
  • The readme “Requires at least” value is valid: 6.4.
  • The PHP “Requires at least” header is a numeric version: 6.4.
  • “Requires at least” matches between the readme and PHP header: 6.4.
  • The readme “Requires PHP” value is valid: 8.1.
  • The PHP “Requires PHP” header is a numeric version: 8.1.
  • “Requires PHP” matches between the readme and PHP header: 8.1.
  • “Tested up to” 7.1 meets the minimum WordPress version 6.4.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Screenshot 3 has a matching image and caption.
  • Screenshot 4 has a matching image and caption.
  • Screenshot 5 has a matching image and caption.
  • Screenshot 6 has a matching image and caption.
  • Screenshot 7 has a matching image and caption.
  • Screenshot 8 has a matching image and caption.
  • Screenshot 9 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

@dknauss dknauss mentioned this pull request Nov 30, 2026
5 of 9 tasks
@dknauss
dknauss marked this pull request as ready for review November 30, 2026 06:18
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-30T06:18:38.707039Z
We couldn’t complete this review. Comment @codex review to try again.
2d51851 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

dknauss added a commit that referenced this pull request Nov 30, 2026
Patch release from v1.23.0 with only the fix for #327: the OSCOLA
given-name pattern no longer backtracks on a long run of initials, so a
pasted line of hundreds of initials no longer freezes the editor. The same
fix is on main for 1.24.0 in #329.

Bump the plugin header, block.json, package.json, package-lock.json, and
readme.txt's Stable tag to 1.23.1; add the CHANGELOG section, the readme.txt
changelog and upgrade notice, the README release highlight, and the planning
state baseline.


Claude-Session: https://claude.ai/code/session_01WPtgA2by7WV5UC9oYaXWwd

Co-authored-by: Claude <noreply@anthropic.com>

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.

Free-text parser: OSCOLA given-first name pattern backtracks cubically (from #320)

2 participants