r/ProgrammerHumor • • Oct 13 '26

Advanced myBossWroteASpamFilter

Post image
284 Upvotes

49 comments sorted by

7

u/Bomaruto Oct 13 '26

I think you wrote it for a terrible joke. 

7

u/Paperwolf_ Oct 13 '26

I wish this were the case, but it is not

130

u/DogmaticParadigm87 Oct 13 '26

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

43

u/rosuav Oct 13 '26

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

13

u/FUTURE10S Oct 14 '26

To be fair like 95% of my spam is <my email name>6769@fnck.y00.рф or some shit so I mean I get it

218

u/keatonatron Oct 13 '26

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

174

u/Wonderful-Habit-139 Oct 13 '26

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

69

u/B_bI_L Oct 13 '26

people who wave their birth year in their email:

4

u/ice456cream Oct 17 '26

Name is probably not email

Have you seen a standard contact form?

Name:
Email for us to send a response, maybe:
Body:

And that sends to an internal inbox

40

u/_verel_ Oct 13 '26

Lol what a wonderful explanation xd

14

u/takeyouraxeandhack Oct 14 '26

We call this "intentional programming". It's when you program something and expect it to do what your intentions were and not what you programmed it to do.

11

u/keatonatron Oct 13 '26

Are you spam?

12

u/Own_Purchase_7976 Oct 13 '26

a sentient piece of ham

0

u/Ur-Best-Friend Oct 14 '26

Does it scream when you eat it?

1

u/HaveYouSeenMySpoon Oct 14 '26

Or does it moan?

1

u/Ur-Best-Friend Oct 15 '26

Common mistake, that's Sexual deviant Piece of hAM, also known as SPAM.

16

u/Wonderful-Habit-139 Oct 13 '26

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

70

u/Ethameiz Oct 13 '26

There is IsDigit method for char

53

u/BorderKeeper Oct 13 '26

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

43

u/Freecelebritypics Oct 13 '26

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 

11

u/BorderKeeper Oct 13 '26

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.

20

u/Crispy1961 Oct 13 '26

simple regex

Now thats an oxymoron.

2

u/BorderKeeper Oct 13 '26

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

6

u/jbaker88 Oct 13 '26

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

0

u/BorderKeeper Oct 13 '26

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.

3

u/Makefile_dot_in Oct 14 '26

and then visual studio will say

💡 Suggestion: compile this regex in a constant variable before using it

and then when you click it it will say

💡 Suggestion: instead of compiling this regex, use the regex code generator to generate a method that does what this regex does, polluting the method list of your class

2

u/HTTP_404_NotFound Oct 14 '26

I live regex (Have been a splunk / data admin for years now).

that being said- regex is pretty heavy compared to string.where(o => char.isdigit(o)).Count() > 2

-3

u/Dimencia Oct 13 '26 • Bravo

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

1

u/Ur-Best-Friend Oct 14 '26

Yes yes, you are so cool, we are all very impressed. I'm so impressed I would clap, but we're online, so best I can do is give a clapping emoji, to show just how very impressed I am.

0

u/[deleted] Oct 14 '26

[deleted] — view deleted comment

2

u/Ur-Best-Friend Oct 14 '26

No way, I'll fight you for Norway.

0

u/[deleted] Oct 14 '26

[deleted] — view deleted comment

2

u/Ur-Best-Friend Oct 15 '26

YOU CAN'T CALL DIBS ON A COUNTRY SILLY!

You fight for it. For world piece!

4

u/rosuav Oct 13 '26

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.

72

u/acd124 Oct 13 '26

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

47

u/vita10gy Oct 13 '26

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

9

u/The_MAZZTer Oct 13 '26

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

9

u/mortenmoulder Oct 13 '26

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

1

u/tommy71394 Oct 14 '26

Only if it ain't async, just toss the email sending task itself to a queue, api will respond more or less the same timing be it success or failure

1

u/-Redstoneboi- Oct 16 '26

the email send is awaited before the response

2

u/tommy71394 Oct 16 '26

Oh shit HAHAHAHA I didn't notice, I saw the function was async and didn't notice the await at the front

2

u/acd124 Oct 13 '26

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.

10

u/The_Weeaboo_Nextdoor Oct 13 '26

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

19

u/Pim08UO Oct 13 '26

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

6

u/WawaTheFirst Oct 13 '26

No problem. You can mail them instead.

3

u/YellowJarTacos Oct 13 '26

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

2

u/svenissimo Oct 15 '26

I worked at a big company that liked to use first.last@company for emails.

There was a glitch and they couldn’t give me mine despite not being used and the system added -199 on my last name.

Only time I never got a single piece of junk mail in 10years.

1

u/Childermass13 Oct 13 '26

Amazing! I have the same combination on my luggage!

-3

u/tatstytastycakes Oct 13 '26

wait are you using namespace std? shame on you.

5

u/blehmann1 Oct 13 '26

This isn't C++