|
|
|
|
|
by betterunix
4688 days ago
|
|
"this is done by escaping inputs" Something about that sounds wrong. It is as though you are suggesting that we use in-band signaling with a bunch of notch filters to ensure that Cap'n Crunch whistles cannot be used to get free calls. The right answer is out-of-band signaling -- in other words, not constructing queries / command strings / etc. from user inputs. Major SQL databases all support prepared statements; this seems like a far more robust approach than trying to sanitize inputs. |
|
Imagine constructing a function in some other language this way:
This is obviously wrong. Now, let's say I suggest fixing it with escaping: Any sane programming community would string me up by my thumbs for doing this, and rightly so.Yet, do the exact same thing in SQL and it's just business as usual. Occasionally people talk about prepared statements and parameterized queries and such, but usually people just talk about escaping. As if the problem is just that you need more backslashes, not that you're glomming strings together at runtime and then calling eval() on them.
It's so bizarre. People would think you're crazy for doing it in one environment, but doing it in a different environment where the exact same problems are present is just fine! I can't fathom how we got to this place.