Skip to content

Fix quadratic conversation fence parsing (C-015) - #39

Merged
nickmisasi merged 1 commit into
rebuild/rhs-dashboardfrom
cursor/fix-c015-segments-35b5
Aug 31, 2026
Merged

Fix quadratic conversation fence parsing (C-015)#39
nickmisasi merged 1 commit into
rebuild/rhs-dashboardfrom
cursor/fix-c015-segments-35b5

Conversation

@nickmisasi

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the catastrophic-backtracking fence regex in parseSegments with a linear, line-based scanner.
  • An unterminated fence (``` + a long line with no closer) is now O(n) plain text instead of Θ(n²) regex backtracking.
  • ConversationMessage memoizes parse results on message.text.

Fixes teamsecure C-015 on the RHS dashboard branch. Stacked on #35.

Testing

  • npm test -- --watchAll=false src/utils/segments.test.ts (7/7, 200k-char case ~1ms)
  • npm test -- --watchAll=false (102/102)
  • npm run check-types

Release Note

NONE
Open in Web Open in Cursor 

Replace the ReDoS-prone fence regex in parseSegments with a linear
line-based scan (C-015) and memoize parse on ConversationMessage.

Co-authored-by: Nick Misasi <nick13misasi@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 91df2bf1-dca4-4d3b-a312-4049659337da

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@nickmisasi
nickmisasi marked this pull request as ready for review August 31, 2026 15:11
@nickmisasi
nickmisasi merged commit e49ab7c into rebuild/rhs-dashboard Aug 31, 2026
2 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T15:18:48.142624Z 3d87c03 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved. Cursor Bugbot and Cursor Security Agent were not present after the first check poll, so those signals were skipped, and no approval policy required human review. Reviewers were not assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d87c03215

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

function isFenceCloser(line: string): boolean {
return line.trim() === '```';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match the closing fence length to the opener

When an assistant uses a valid four-or-more-backtick fence—commonly needed to show triple backticks inside the code—isFenceOpener accepts it via startsWith('```'), but a matching delimiter is rejected here because the closer must be exactly three backticks. Consequently close remains -1 and the entire fenced block renders as plain text; record the opening run length and accept a closing run of at least that length.

Useful? React with 👍 / 👎.

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