devtools-unicode-escaping

Installation
SKILL.md

Unicode Escaping and User-Controlled Data Guidelines

When displaying inspected data, user-controlled strings, or untrusted input in the DevTools UI (e.g., console messages, object properties, DOM tree nodes, or UI titles/descriptions), you must ensure they are properly escaped to prevent layout bleed-through (such as Right-to-Left leaks) or security vulnerabilities.

DevTools provides two primary Unicode escaping functions in Platform.StringUtilities:

1. Escaping for Text Representation (escapeUnicodeAsText)

Use Platform.StringUtilities.escapeUnicodeAsText(content) when rendering values that developers need to inspect (e.g. string values inside the Console or the Object properties view) where hidden, invisible, or formatting characters should be made explicitly visible.

  • Behavior: Escapes all formatting and surrogate characters into literal Unicode escape sequences (e.g., \u202E, \u200B).
  • Example Usage:
    const text = Platform.StringUtilities.escapeUnicodeAsText(JSON.stringify(description));
    

2. Escaping for UI Rendering (safeEscapeUnicode)

Use Platform.StringUtilities.safeEscapeUnicode(content) when rendering content inside templates or HTML markup where you want safe layout-critical zero-width formatting characters to function normally for word wrapping or rendering layout, but want to escape dangerous layout-disrupting characters (like bidi overrides).

Installs
2
GitHub Stars
4.1K
First Seen
Nov 6, 2026