Censor specific text patterns

Hi, I saw in Discourse that there is a way to censor words in admin/site_settings/category/posting - does anyone know of a way to censor specific patterns? For example, I foresee HR people eventually using the Discourse forum and to protect them from themselves posting sensitive info I want to automatically remove SSNs (i.e. XXX-XX-XXXX). Has anyone had this need before and found a way to do it?

Please share any advice :smile:

Cheers,
Chris

1 Like

We don’t support censoring wildcards or regular expressions, would probably need to be a plugin.

1 Like

Something like this would also be useful for the inclusion of full email addresses being discussed in other topics right now and caused by HTML email parsing bugs.

This would absolutely require the work that @zogstrip is doing around hoisting out code and pre blocks in the pipeline earlier.

Thanks Jeff. If @zogstrip needs help testing at any point I would be happy to help :smile:.

How is it related to the hoisting of code blocks?

Honestly, not sure…just asked about censoring text patterns. Jeff mentioned you were working on something related, maybe he can clarify :slight_smile:?

The regex to block, say, a phone number pattern, would match inside pre and code blocks unless they were hoisted out very early in the pipeline.

2 Likes

Ok, so now that it’s done, @optimus, you’ll need to write a plugin :wink:

Something like (not tested)

Discourse.Dialect.addPreProcessor(function(text) {
   return text.replace(/your-regexp/g, "your replacement");
}); 

This now exists, see

1 Like