Skip to main content

redact

Function redact 

Source
pub fn redact(input: &str, allow: &[String]) -> Redacted
Expand description

Replace every secret in input. A match that lies entirely inside one of the allow strings (compared literally) is left as it is.

The text is scanned again after a replacement until a scan finds nothing, because a replacement can change what a neighbouring pattern sees: a private key block that sat inside the password of a URL, say, took the spaces that kept that URL from being one. That is what makes the result idempotent by construction rather than by luck; it is bounded, and every extra scan is a cheap read over text that is already a marker or plain.