all repos — sz-chrome-remote-cdp @ 60ddf56f1db548456538c70bd6254e519d734bf8

pi-browser-harness, patched to drive a Chrome on another host over CDP, with castle_cdp_search web search

docs(util): clarify safeJs trust boundary and unsupported value types
amankumarsingh77 amankumarsingh7702@gmal.com
Sat, 02 May 2026 15:38:07 +0530
commit

60ddf56f1db548456538c70bd6254e519d734bf8

parent

31afcecdd849529bc5d6ae0719313f0f37e7cebc

1 files changed, 10 insertions(+), 3 deletions(-)

jump to
M src/util/js-template.ts → src/util/js-template.ts

@@ -3,9 +3,16 @@ * Build a JavaScript source string with safely-interpolated values.

* Every interpolated value is JSON.stringify'd, so strings, numbers, * objects, and special characters all become valid JS literals. * - * This is the ONLY supported way to build evaluation source in the - * codebase — never use raw template literals for JS that crosses the - * CDP boundary. + * This is the ONLY supported way to interpolate untrusted values into + * evaluation source — never use raw template literals for JS that + * crosses the CDP boundary. The static parts of the template (the + * `strings` array) must remain hard-coded; only the `${...}` slots + * are sanitized. + * + * Values must be JSON-serializable: BigInt and Symbol throw at runtime; + * functions and undefined serialize to `undefined`/omitted, which yields + * a ReferenceError when evaluated. Pass strings, numbers, booleans, + * plain objects, or arrays. */ export const safeJs = ( strings: TemplateStringsArray,