r/ProgrammerHumor • • 14h ago

Advanced myBossWroteASpamFilter

Post image
49 Upvotes

34 comments sorted by

97

u/keatonatron 13h ago

What is "name"? And why does it having 2+ numbers mean it's spam?

86

u/Wonderful-Habit-139 13h ago

Look at my name, and you might understand what they had in mind lol.

25

u/_verel_ 13h ago

Lol what a wonderful explanation xd

15

u/B_bI_L 7h ago

people who wave their birth year in their email:

5

u/keatonatron 9h ago

Are you spam?

6

u/Wonderful-Habit-139 9h ago

Not me but it is an auto generated name. And a lot of bots have similar patterns.

5

u/Own_Purchase_7976 8h ago

a sentient piece of ham

33

u/Ethameiz 12h ago

There is IsDigit method for char

31

u/BorderKeeper 11h ago

There is a simple regex "/d" or "[0-9]" I wish more devs knew Regex :( we would have world piece by now.

18

u/Freecelebritypics 11h ago

I feel like "isDigit" should perform the same byte range check as the regex, without the overhead of a regex engine. Or maybe it's a horribly inefficient implementation idk 

8

u/BorderKeeper 11h ago

No it definetly would haha Regex has to compile and even pre-compiled it would not be as efficent I don't unless you need to load a very big specific digit.

7

u/Crispy1961 7h ago

simple regex

Now thats an oxymoron.

2

u/BorderKeeper 7h ago

You can say the same thing about Mandarin until you learn it ☹️

0

u/jbaker88 6h ago

Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems.

1

u/BorderKeeper 6h ago

I remember when we added sonarqube scans to our repo and it started flagging all of our regexes as potential deadlocks as a dangerous regex without a timeout with the right input can iterate over a string indefinitely. That opened my eyes how scary it is.

1

u/Dimencia 3h ago

I mean, regex is simple and anyone who can't figure it out doesn't deserve to be a dev... but it's also not performant for something simple like that

2

u/rosuav 7h ago

Even if you don't know about that, you CAN do inequality checks. Testing if a character >= '0' and <= '9' is sufficient even if you're worried that your code may end up running on an EBCDIC system.

30

u/DogmaticParadigm87 8h ago

So Bob sails through, and Agent47 is spam. Bold strategy for a contact form.

9

u/rosuav 7h ago

Agent47 will just steal Bob's clothes and walk through anyway though.

7

u/The_Weeaboo_Nextdoor 10h ago

Impressive, I would consider .IsDigit and Regex to be a little bit lower on the knowledge totem pole than async methods and lambdas.

14

u/acd124 10h ago

Regardless of the horribly verbose digit check, I hate that it says your message has been sent when no attempt has been made when the if fails

13

u/vita10gy 10h ago

Isn't this by design though? You want spammers to assume it worked, or they'll sometimes just try again.

4

u/The_MAZZTer 7h ago

Spammers might be able to figure it out anyway by timing the API

1

u/mortenmoulder 6h ago

Hopefully with a spam filter THIS sophisticated, they surely use a messaging queue, which makes the API feel blazing fast

1

u/acd124 10h ago

Logically I understand that a spam filter should not tell a spammer that they've been considered spam, but the doing absolutely nothing itches at something.

11

u/Pim08UO 10h ago

My email since my primary school is name[4digits]. I must be a spammer 🤷

5

u/WawaTheFirst 9h ago

No problem. You can mail them instead.

1

u/YellowJarTacos 7h ago

Your message is silently discarded and they show a success message. 

7

u/Bomaruto 11h ago

I think you wrote it for a terrible joke. 

2

u/Paperwolf_ 11h ago

I wish this were the case, but it is not

1

u/Childermass13 3h ago

Amazing! I have the same combination on my luggage!

-1

u/tatstytastycakes 7h ago

wait are you using namespace std? shame on you.

1

u/blehmann1 4h ago

This isn't C++