# Blocking email addresses using profanity filter?

**URL:** https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759
**Category:** Support
**Created:** [February 17, 2016, 10:42pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759 "2016-02-17T22:42:22Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 17, 2016, 10:42pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/1 "2016-02-17T22:42:22Z")

</div>

Continuing the discussion from [Inappropriate / Obscenity / Profanity Language Filter](https://meta.discourse.org/t/inappropriate-obscenity-profanity-language-filter/7993):

So the profanity filter works well … not that we see it used often.

But is there a way to add regex/patterns so it could block people from putting an email address in a post?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 18, 2016, 12:37am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/2 "2016-02-18T00:37:30Z")

</div>

That would be extremely dangerous, though.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 18, 2016, 1:31am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/3 "2016-02-18T01:31:34Z")

</div>

> [@codinghorror](#):
>
> That would be extremely dangerous, though.

“Extremely dangerous” is a strong phrase. Can you say more about why you feel that way?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 18, 2016, 1:44am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/4 "2016-02-18T01:44:15Z")

</div>

> **[Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?](https://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/)**
>
> I’m not a huge fan of The Daily WTF for reasons I’ve previously outlined. There is, however, the occasional gem – such as this one posted by ezrec:
> 
> Browsing through a web archive of some old computer club conversations, I ran across this...

Etc etc etc

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [February 18, 2016, 1:50am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/5 "2016-02-18T01:50:51Z")

</div>

Regex is like a language unto itself. Even a lot of seasoned programmers have trouble with it.

Using it requires not only understanding every possible variation you want to match, but also every possible variation you want to not match.

A lot of people do fairy well with the first, but fail with the second.

For example, using `(.)*` matches everything, anything, and nothing.  
I see it used way too often as a “short cut” to get things to match, but unfortunately it often results in matching what it shouldn’t.

I guess if it were under the “developers only” section it might be enough to scare off Admins that shouldn’t mess with it. But human nature being what it is, give out loaded guns and it’s only a matter of time before someone shoots themselves in their foot.

And as for a valid email regex, it is notoriously difficult to craft a fool-proof one. Many come close and are “good enough” but without additional processing there will likely be problems at some point.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 18, 2016, 1:51am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/6 "2016-02-18T01:51:20Z")

</div>

Fair enough, but the filter already exists in Discourse, even if you aren’t using it personally. Also, keep in mind (in response to your blog post) that the Discourse filter doesn’t replace strings, it masks them with squares. 🙂

Regexes are inherently difficult, so I’m not necessarily proposing that you ask everyday users to use them as the mainstream use case. The current system works fine for most cases, but there’s no way to surefire way prevent people from posting most common email addresses. (I am not interested in the debate on the “perfect” email regex.)

Meanwhile, I’m simply blocking some of the most common domain names like `@gmail.com`, `@yahoo.com`, etc.

> [@Mittineague](#):
>
> And as for a valid email regex, it is notoriously difficult to craft a fool-proof one. Many come close and are “good enough” but without additional processing there will likely be problems at some point.

I am not interested in letting perfect get in the way of good here. Just trying to prevent the most common occurrences.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [February 18, 2016, 1:54am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/7 "2016-02-18T01:54:43Z")

</div>

> [@downey](#):
>
> the Discourse filter doesn’t replace strings

Actually, last I knew it replaces the characters with the box decimal value

eg. blocking “@gmail.com”, “[someone@gmail.com](mailto:someone@gmail.com)” would look like

someone■■■■■■■■■■

and the source would be

```plaintext
someone&#9632;&#9632;&#9632;&#9632;&#9632;&#9632;&#9632;&#9632;&#9632;&#9632; 

```

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [February 18, 2016, 1:56am UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/8 "2016-02-18T01:56:18Z")

</div>

> [@Mittineague](#):
>
> Actually, last I knew it replaces the characters with the box decimal value

That is what I meant when I finished the sentence with:

> [@downey](#):
>
> it masks them with squares.

Forgive my error of specificity. What I meant was that it doesn’t replace it with other letters to change the word, as described in the blog post above. 😉

---

<div class="post-metadata">

### Author: ![outofthebox](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outofthebox/32/83708_2.png) [@outofthebox](https://meta.discourse.org/u/outofthebox)
#### Post date: [September 24, 2019, 12:11pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/9 "2019-09-24T12:11:41Z")

</div>

Hi,

So, I’m interested in preventing people from sharing their email address in public discussions in our community, for the sake of their privacy (perhaps some people don’t realize, despite our best efforts, that the discussions are public?).

Would this be suitable? Or would it have significant risks I am not appreciating?

```
*@*.com
*@*.org
*@*.net
*@*.edu
*@*.info
*@*.biz

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 24, 2019, 12:33pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/10 "2019-09-24T12:33:15Z")

</div>

All regexes carry huge risk, the more broad, the more risk. Those are.. quite risky.

---

<div class="post-metadata">

### Author: ![outofthebox](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/outofthebox/32/83708_2.png) [@outofthebox](https://meta.discourse.org/u/outofthebox)
#### Post date: [September 24, 2019, 2:25pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/11 "2019-09-24T14:25:26Z")

</div>

My naive hope would be that the “@” and the inclusion of top level domains would narrow it down to just email addresses. Is there no way to target these?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 24, 2019, 2:40pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/12 "2019-09-24T14:40:47Z")

</div>

Something like `*.?@gmail.com` would be significantly safer. Ideally I would say word characters only not asterisk (all chars) too.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/blocking-email-addresses-using-profanity-filter/39759/13 "2024-06-08T12:37:08Z")

</div>

This topic was automatically closed after 3033 days. New replies are no longer allowed.
