fix(douban/subject): self-contained splitDoubanTitle for page.evaluate injection (#1851) - #1924
Merged
jackwener merged 1 commit intoJun 13, 2026
Conversation
…aluate injection
loadDoubanMovieSubject injects `${splitDoubanTitle.toString()}` into a
page.evaluate string, but the function body called the module-level
`normalizeText`, which does not exist in the page context — so
`opencli douban subject <id>` threw `ReferenceError: normalizeText is not
defined` (jackwener#1851).
Inline a local `normalizeText` inside `splitDoubanTitle` (equivalent to the
module helper) so the serialized function is self-contained, and export it
for the regression test. Node-side callers are unaffected.
Verified: `douban subject 37116446` returns movie details again; 4 new
regression tests reproduce the injection in a normalizeText-free scope
(red before fix, green after); `vitest run clis/douban/` → 27 passed.
Fixes jackwener#1851
9 tasks
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.
What
opencli douban subject <id>crashes withReferenceError: normalizeText is not defined(#1851).loadDoubanMovieSubjectinjects${splitDoubanTitle.toString()}into apage.evaluatestring, butsplitDoubanTitle's body calls the module-levelnormalizeText— which doesn't exist in the page context. The serialized function loses its module closure, so the command throws every time.Fix
Inline a local
normalizeTextinsidesplitDoubanTitle(identical to the module helper) so the serialized function is self-contained, andexportit for the regression test. The module-levelnormalizeTextand all Node-side callers are unchanged.Verification
opencli douban subject 37116446(the id from [Bug]: opencli douban subject <id> command error, unable to query movie details #1851) now returns full movie details — noReferenceError.splitDoubanTitlefrom its.toString()in a fresh scope with no module-levelnormalizeText(the page.evaluate model): red before the fix, green after.vitest run clis/douban/→ 27 passed.Fixes #1851