zero-width-strip 0.1.0

Strip zero-width and bidi-control Unicode characters from text. Defends against invisible-payload prompt injection. Zero deps.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 4 items with examples
  • Size
  • Source code size: 18.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 250.37 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 20s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • MukundaKatta/zero-width-strip
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MukundaKatta

zero-width-strip

crates.io

Strip zero-width and bidi-control Unicode chars from text. Closes the "invisible payload" prompt-injection channel.

use zero_width_strip::{strip, has_invisible};
let dirty = "hello\u{200B}\u{202E}world";
assert!(has_invisible(dirty));
assert_eq!(strip(dirty), "helloworld");

Covers U+200B–U+200F, U+202A–U+202E, U+2060–U+2064, U+2066–U+2069, U+180E, U+FEFF. Zero deps. MIT or Apache-2.0.