Skip to content

fix(cli): preserve caption text inside script blocks - #5226

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/cli-caption-script-escaping
Oct 8, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/cli-caption-script-escaping

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

Importing caption text containing </script> through hyperframes transcribe can close the destination script and turn part of the caption into HTML. Replacement-string sequences such as $& and $$ also change the text or word IDs during insertion.

Escape < after JSON serialization and insert the serialized data through a replacement callback. This applies Studio's existing script-data convention to the CLI patcher and preserves literal caption text, IDs and timing for both supported variable names.

Validation:

  • Five fail-first failures; nine regressions cover closing-tag forms, escaped script state, dollar sequences, quotes, backslashes and Unicode.
  • All 223 transcription tests pass (one existing skip).
  • Built CLI plus Chromium preserves text and IDs across 18 cases; repeated imports are byte-stable and input files remain unchanged.
  • All 18 composition fixtures pass lint and strict browser check, with 9 layout and 5 contrast samples each.
  • CLI build/typecheck, repository lint, formatting, commit hooks, comment checks, deletion and test-reachability checks pass.

This follows the generator fix in #3847. Transcript array-boundary parsing in #3896 remains separate.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two real escaping gaps in the caption patcher. A literal </script> in word text closes the host script, and $&, $' or $$ in the text are expanded by String.replace. Escaping < matches what Studio's caption generator already does, and the replacement callback removes the dollar-pattern expansion. The tests fail on main and pass here. Please land this before or together with #5236, which makes a decoded < reachable from VTT imports.

— Rames

@jrusso1020
jrusso1020 enabled auto-merge October 8, 2026 19:34
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 8, 2026
Merged via the queue into heygen-com:main with commit c9c9f4d Oct 8, 2026
80 checks passed
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