Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbayer committed Mar 21, 2023
1 parent f96e9d4 commit a8ee53c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion relay-general/src/pii/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,22 @@ fn apply_regex_to_chunks<'a>(
// on the chunks, but the `regex` crate does not support that.

let mut search_string = String::new();
let mut has_text = false;
for chunk in &chunks {
match chunk {
Chunk::Text { text } => search_string.push_str(&text.replace('\x00', "")),
Chunk::Text { text } => {
has_text = true;
search_string.push_str(&text.replace('\x00', ""));
}
Chunk::Redaction { .. } => search_string.push('\x00'),
}
}

if !has_text {
// Nothing to replace.
return chunks;
}

// Early exit if this regex does not match and return the original chunks.
let mut captures_iter = regex.captures_iter(&search_string).peekable();
if captures_iter.peek().is_none() {
Expand Down

0 comments on commit a8ee53c

Please sign in to comment.