Skip to content

fix: use JSON.stringify for safe JS string interpolation in evaluate()#109

Merged
jackwener merged 1 commit intojackwener:mainfrom
ByteYue:fix_release_ci
Mar 20, 2026
Merged

fix: use JSON.stringify for safe JS string interpolation in evaluate()#109
jackwener merged 1 commit intojackwener:mainfrom
ByteYue:fix_release_ci

Conversation

@ByteYue
Copy link
Contributor

@ByteYue ByteYue commented Mar 20, 2026

Description

Replace ad-hoc string escaping with JSON.stringify() for values interpolated into JavaScript code strings passed to page.evaluate().

  • explore.ts: clickLabels were escaped with only single-quote replacement, which breaks on labels containing backslashes or newlines. JSON.stringify() handles all edge cases correctly.

  • synthesize.ts: buildEvaluateScript() embedded URLs directly inside single quotes. JSON.stringify() safely handles URLs containing special characters.
    Related issue:

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Screenshots / Output

Replace ad-hoc string escaping with JSON.stringify() for values
interpolated into JavaScript code strings passed to page.evaluate().

- explore.ts: clickLabels were escaped with only single-quote
  replacement, which breaks on labels containing backslashes or
  newlines. JSON.stringify() handles all edge cases correctly.

- synthesize.ts: buildEvaluateScript() embedded URLs directly inside
  single quotes. JSON.stringify() safely handles URLs containing
  special characters.
@jackwener jackwener merged commit 390dbe7 into jackwener:main Mar 20, 2026
9 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