fix: mergeplots leak when initPicture is absent from plotb#7
Open
anhbui5302 wants to merge 2 commits into
Open
fix: mergeplots leak when initPicture is absent from plotb#7anhbui5302 wants to merge 2 commits into
anhbui5302 wants to merge 2 commits into
Conversation
…sent The legacy-format branch in mergeplots required `initPicture(...)` in plotb's script attribute. When merging an ineqbetweenplot() output with a modern showplot()-derived plot whose script lacked that prefix, preg_replace returned plotb verbatim and the entire second <embed> tag was injected into plota's script attribute — so the browser rendered the outer embed and showed the inner script as fallback text below the graph. Pull script content directly and strip any setBorder/initPicture/axes prefix instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…y semicolon showplot() can emit a script payload that begins with an empty statement (e.g. `; initPicture(...); axes(...);; plot(...)`). The previous strip regex anchored on `^\s*`, so the leading `;` blocked the match and the full `initPicture(...); axes(...);` got appended to plota — the duplicate initPicture then cleared the canvas, erasing earlier draws. Allow `[;\s]*` between segments so stray empty statements are absorbed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
76bd499 to
53bca09
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mergeplots()requiredinitPicture(...)inplotb's script attribute. When merging anineqbetweenplot()output with a modernshowplot()-derived plot whose script lacked that prefix,preg_replacereturnedplotbverbatim and the entire second<embed>tag was injected intoplota'sscript='…'attribute. The browser then rendered the outer embed and showed the leaked inner script as fallback text below the graph.plotbdirectly withpreg_match, then strip anysetBorder/initPicture/axesprefix before appending. Works with both legacy (setBorder; initPicture; axes; …) and modern (axes; …) embed shapes.ineqbetweenplot()shaded regions with amergeplots()ofshowplot()line segments — the explanation rendered the function graph correctly but spilled the SVG path commands as text below the plot.Test plan
vendor/bin/codecept run unit AddlabelTest— 10/10 pass; added two new cases that fail without the fix (single-<embed>invariant + ineqbetweenplot fill/path payload preservation)vendor/bin/codecept run unit DrawFunctionDescriptionTest— 63/63 passproblems.phpthat the merged solution contains exactly one<embed>tag with all expectedpath(...)andfill=...commands concatenated into a singlescriptattribute (no nested embed, no premature single-quote termination)🤖 Generated with Claude Code