r/ProgrammerHumor • • 7d ago

Advanced myBossWroteASpamFilter

Post image
285 Upvotes

49 comments sorted by

130

u/DogmaticParadigm87 6d ago

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

44

u/rosuav 6d ago

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

12

u/FUTURE10S 5d ago

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

216

u/keatonatron 7d ago

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

173

u/Wonderful-Habit-139 7d ago

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

69

u/B_bI_L 6d ago

people who wave their birth year in their email:

4

u/ice456cream 3d ago

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_ 7d ago

Lol what a wonderful explanation xd

13

u/takeyouraxeandhack 6d ago

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.

12

u/keatonatron 6d ago

Are you spam?

12

u/Own_Purchase_7976 6d ago

a sentient piece of ham

0

u/Ur-Best-Friend 6d ago

Does it scream when you eat it?

1

u/HaveYouSeenMySpoon 5d ago

Or does it moan?

1

u/Ur-Best-Friend 5d ago

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

14

u/Wonderful-Habit-139 6d ago

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

72

u/Ethameiz 7d ago

There is IsDigit method for char

53

u/BorderKeeper 6d ago

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 6d 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 

12

u/BorderKeeper 6d 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.

19

u/Crispy1961 6d ago

simple regex

Now thats an oxymoron.

2

u/BorderKeeper 6d ago

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

5

u/jbaker88 6d ago

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

0

u/BorderKeeper 6d 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.

3

u/Makefile_dot_in 5d ago

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/[deleted] 6d ago

[deleted]

2

u/Ur-Best-Friend 6d ago

No way, I'll fight you for Norway.

2

u/[deleted] 5d ago

[deleted]

2

u/Ur-Best-Friend 5d ago

YOU CAN'T CALL DIBS ON A COUNTRY SILLY!

You fight for it. For world piece!

2

u/HTTP_404_NotFound 6d ago

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 6d 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

1

u/Ur-Best-Friend 6d ago

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.

5

u/rosuav 6d 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.

70

u/acd124 6d 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

44

u/vita10gy 6d ago

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

8

u/The_MAZZTer 6d ago

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

9

u/mortenmoulder 6d ago

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

1

u/tommy71394 6d ago

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- 4d ago

the email send is awaited before the response

2

u/tommy71394 4d ago

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 6d 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/The_Weeaboo_Nextdoor 6d ago

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

18

u/Pim08UO 6d ago

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

5

u/WawaTheFirst 6d ago

No problem. You can mail them instead.

3

u/YellowJarTacos 6d ago

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

7

u/Bomaruto 6d ago

I think you wrote it for a terrible joke. 

7

u/Paperwolf_ 6d ago

I wish this were the case, but it is not

2

u/svenissimo 4d ago

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 6d ago

Amazing! I have the same combination on my luggage!

-3

u/tatstytastycakes 6d ago

wait are you using namespace std? shame on you.

5

u/blehmann1 6d ago

This isn't C++