mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-17 21:17:23 +02:00
fix(browse): sanitize lone Unicode surrogates at commandResult chokepoint + /batch envelope (#1440)
Page captures with mixed-script Unicode round-trip cleanly to the Claude API. Two new utilities in browse/src/sanitize.ts: stripLoneSurrogates for raw UTF-16 strings, stripLoneSurrogateEscapes for \uXXXX JSON escape text. sanitizeBody picks the right pass based on cr.json. buildCommandResponse is extracted from handleCommand (now exported) and applies sanitization before new Response(). /batch was bypassing this chokepoint via direct JSON.stringify, so it sanitizes each cr.result before pushing AND wraps the envelope with stripLoneSurrogateEscapes. Defense in depth wraps at getCleanText, getCleanTextWithStripping, html, accessibility, and snapshot.ts return points so downstream consumers (datamarking, envelope wrapping) see sanitized text before the response is built. 25 new unit tests across sanitize.test.ts and build-command-response.test.ts. content-security.test.ts updated to accept either pre- or post-sanitize form of the snapshot scoped branch (source-level regression check). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -769,6 +769,8 @@ noting which items are incomplete. Do not loop indefinitely.
|
||||
|
||||
## Phase 4: Final Approval Gate
|
||||
|
||||
{{TASKS_SECTION_AGGREGATE}}
|
||||
|
||||
**STOP here and present the final state to the user.**
|
||||
|
||||
Present as a message, then use AskUserQuestion:
|
||||
@@ -819,6 +821,10 @@ I recommend [X] — [principle]. But [Y] is also viable:
|
||||
|
||||
### Deferred to TODOS.md
|
||||
[Items auto-deferred with reasons]
|
||||
|
||||
### Implementation Tasks (aggregated across phases)
|
||||
[Substitute the contents of $AGGREGATED_TASKS computed above. If empty:
|
||||
"_No per-phase task lists found in $TASKS_DIR for branch $BRANCH._"]
|
||||
```
|
||||
|
||||
**Cognitive load management:**
|
||||
|
||||
Reference in New Issue
Block a user