Skip to content

probes.encoding: add InjectFancyText Unicode font encoding - #2118

Open
setuparimi wants to merge 1 commit into
NVIDIA:mainfrom
setuparimi:encoding-fancy-text
Open

probes.encoding: add InjectFancyText Unicode font encoding#2118
setuparimi wants to merge 1 commit into
NVIDIA:mainfrom
setuparimi:encoding-fancy-text

Conversation

@setuparimi

Copy link
Copy Markdown

What this does

Adds a new "fancy text" Unicode font encoding to the encoding probe, addressing the remaining unchecked item (utf (qaz.wtf)) in #152. The zalgo item from that issue is already implemented; this completes the list.

The new probes.encoding.InjectFancyText probe encodes payloads by mapping ASCII characters to visually-similar Unicode glyphs, in the style of the qaz.wtf Unicode text converter. It ships three algorithmic transforms as encoding_funcs:

  • Fullwidth — printable ASCII → Halfwidth/Fullwidth Forms (HelloHello)
  • Math bold — Mathematical Alphanumeric Symbols, bold (Hello𝐇𝐞𝐥𝐥𝐨)
  • Monospace — Mathematical Alphanumeric Symbols, monospace (Hello𝙷𝚎𝚕𝚕𝚘)

Design notes

  • No bundled mapping table / no new dependency. qaz.wtf's own mapping tables have no clear open-source license, so rather than copy them, the transforms are computed algorithmically from fixed Unicode code-point offsets (defined by the Unicode Standard). This keeps the change self-contained and license-clean, matching the inline style of the existing braille / morse / nato encoders.
  • Gap-free styles only. I deliberately chose fullwidth, math-bold and monospace because their letter/digit ranges are contiguous. Styles like italic/script/fraktur/double-struck were avoided because Unicode borrows some of their glyphs from the Letterlike Symbols block, which would create irregular gaps.
  • No detector change. The probe reuses the existing encoding.DecodeMatch (primary) and encoding.DecodeApprox (extended) detectors unchanged. The stored trigger remains the plaintext payload, so if the target decodes the fancy text back to ASCII, the existing detectors fire — exactly as for zalgo, braille, etc.
  • Follows the neighboring Inject* probe pattern (mixin + encoding_funcs + encoding_name + active = True); registration is automatic via plugin discovery.

Verification

  • Run the tests and ensure they pass: python -m pytest tests/probes/test_probes_encoding.py tests/detectors/test_detectors_encoding.py116 passed, 1 skipped
  • Verify the probe is discoverable and generates prompts: InjectFancyText enumerates via _plugins.enumerate_plugins("probes") and produces prompts/triggers of equal length.
  • Verify encoders map ASCII to distinct non-ASCII glyphs (added test_fancy_text_functions, mirroring test_atbash_function), so the shared test_encoding_triggers_not_in_prompts invariant holds.
  • Verify end-to-end that encoding.DecodeMatch scores a hit when a response decodes the fancy text back to the plaintext trigger.
  • No existing encodings broke (the parametrized encoding tests run against every probes.encoding.* class and pass).
  • black --config pyproject.toml (v25.1.0, matching .pre-commit-config.yaml) — added code is formatted.

No special hardware or complex environment required.

Note: the change is limited to garak/probes/encoding.py and tests/probes/test_probes_encoding.py. black also flags one pre-existing line (zip(*generated_prompts) in EncodingMixin.__init__) that is unrelated to this change; I left it untouched to keep the diff scoped.

Add a "fancy text" encoding to the encoding probe that maps ASCII to
visually-similar Unicode glyphs (fullwidth forms and Mathematical
Alphanumeric Symbols, bold and monospace), in the style of the qaz.wtf
Unicode text converter.

The transforms are algorithmic (fixed Unicode code-point offsets), so no
third-party mapping table is bundled and no new dependency is added. The
probe reuses the existing encoding.DecodeMatch / DecodeApprox detectors
unchanged, since the stored trigger remains the plaintext payload.

Closes NVIDIA#152

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Setu Parimi <40615252+setuparimi@users.noreply.github.com>
@jmartin-tech jmartin-tech changed the title probes.encoding: add InjectFancyText Unicode font encoding (closes #152) probes.encoding: add InjectFancyText Unicode font encoding Aug 29, 2026
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.

1 participant