this post was submitted on 19 Jul 2023
426 points (97.1% liked)

Programmer Humor

19551 readers
1012 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
all 11 comments
sorted by: hot top controversial new old
[–] [email protected] 57 points 1 year ago (1 children)
[–] [email protected] 2 points 1 year ago

Sometimes you know before opening the comments what the top one will be

[–] [email protected] 51 points 1 year ago

I thought that was the first rule of rendering web content? Or was it protocol parsers?

I remember, it was first rule of video game character creation screens:

choose wisely: wisely

[–] [email protected] 28 points 1 year ago

Second rule of SQL: Never trust user input. Third rule of SQL: Never trust user input.

[–] [email protected] 24 points 1 year ago (1 children)

Honestly, this is a good rule for programming in general. With user input, make sure it's in its own area where it can't interact with anything else and make sure to read and process in such a way that it can't fuck with the operation of the program.

[–] [email protected] 4 points 1 year ago

It should be the first rule of building any formatted string. I see code daily building HTML, JSON, CSS, CSV, shell scripts or whatever just by bashing strings together. If you are lucky they do some form of escaping most of the time.

Really we should get in the habit of using proper encoders. Don't think of these types as just strings you can substitute into, use some library that will actually write these things properly. Thankfully JS has JSON.stringify and good object literals so at least you don't see shitty JSON encoding often (just sometimes when embedded in HTML). I wonder if adding string interpolation was a mistake. It makes it so easy to do the wrong thing. Of course there are cases where you want to format `Hello ${user.name}` or other human readable strings. But more often than not I see it being used incorrectly.

[–] [email protected] 14 points 1 year ago

Ahh yes, the little Bobby tables rule

[–] [email protected] 13 points 1 year ago (1 children)
[–] [email protected] 6 points 1 year ago

I also satanise every input I can, as an extra level of security.

[–] [email protected] 8 points 1 year ago

All your base are drop to us!