fix: harden large tab-chat image persistence - #2989
Conversation
|
@alectimison-maker is attempting to deploy a commit to the esokullu's projects Team on Vercel. A member of the Team first needs to authorize it. |
The rewritten scanner looked for `;base64,` from the end of the MIME type onward, stopping only at a comma or the end of the string. The regex it replaced required the metadata to start with `;`, so a bare `data:image/png` mention in a transcript simply did not match. The scanner instead ran past the quote and any markup after it until it found the next real image, and the replacement deleted everything in between, storing malformed HTML that was then restored into the DOM. Unmatched markers also scanned to the end of the string each time, which is O(k*n) on the transcripts this code is meant to speed up. Require the parameter section to begin with `;` and consume each `;name=value` with a media-type parameter character class, so a quote, an angle bracket, whitespace, or a comma ends the scan and rejects the match. Covered by a regression test on the bare-mention-then-payload case. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ko4GhesjH6KESXozVNS735
|
Reviewed this and pushed one fix to the branch (f390456). The new scanner diverges from the old regex in a way that can delete transcript content.
The The same missing bound works against the performance goal here: every unmatched The fix requires the parameter section to begin with Behavior now matches the old regex on everything I checked: bare mention then image, non base64 SVG, two normal images, mixed case with a Added a regression test for the bare mention case, run against both builds. Full suite is 2203 passed, 0 failed, including the test that came with this PR. A 6 MB payload with a preceding bare mention strips in about 17 ms. Nothing else in the diff looked wrong to me. The 馃 Review by Claude Code |
Summary
Context
The latest upstream main still contained the implementation discussed in PR #2982. The reported Maximum call stack size exceeded was intermittent: the original code passed two full runs and 20 isolated reproductions in this environment. This change removes the risky large-payload regex path and makes the reported 6 MB scenario explicit in the test suite.
Validation