Repository navigation
FIX: prevent splitting supplementary Unicode surrogate pairs in objectivePreview - #3890
Conversation
…s in objectivePreview (microsoft#3870)
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to preserve Unicode surrogate pairs in objective previews.
No open issues 🎉
What changed in this PR
Fixes issue #3870 by preventing objective preview truncation from splitting supplementary Unicode surrogate pairs in the scenario run table. The change affects display formatting, not stored objectives.
Changes:
- Moves the truncation boundary back when it would split a surrogate pair.
- Adds regression tests for Unicode boundaries, ASCII truncation, unchanged short strings, and fallback text.
| File | Description |
|---|---|
frontend/src/components/AttackResults/attackAttemptFormatting.ts |
Preserves surrogate pairs when truncating objective previews. |
frontend/src/components/AttackResults/attackAttemptFormatting.test.ts |
Tests Unicode boundary handling and existing preview behavior. |
Review effort: Balanced
|
@microsoft-github-policy-service agree |
|
Hi maintainers! I've completed the Microsoft CLA requirement. I noticed that the five GitHub Actions workflows are currently awaiting maintainer approval, and the PR is also waiting for one approving review. Could someone with write access please approve the initial workflow runs and review the contribution when convenient? I've verified the focused tests, TypeScript checks and production build locally. Copilot's review also reported no outstanding issues. Thank you for your time and for reviewing my first contribution to PyRIT! |
Description
Fixes #3870.
objectivePreview()previously truncated JavaScript strings by UTF-16 code unit. When the truncation boundary fell between the high and low surrogates of a supplementary Unicode character, the resulting preview could contain an unpaired surrogate.This change moves the truncation boundary back when necessary, preserving valid Unicode characters without changing the behavior of ordinary ASCII strings.
Tests and Documentation
Added five focused Jest regression tests covering:
Verification:
npm run type-check: passed.npm run build: passed.No documentation changes were necessary for this presentation-only fix.
AI Assistance
Antigravity assisted with implementation and regression test authoring. The contributor takes responsibility for the submitted changes.