4 ms·
Because it's very very hard to "correctly" escape strings you don't control, and it's probably an undecidable problem in the general case. From my point of vie
by tsimionescu 5y ago
Because it's very very hard to "correctly" escape strings you don't control, and it's probably an undecidable problem in the general case.
From my point of view, any API which accepts special strings from users is a massive burden and should be extremely suspect when used in an automatic fashion.
Sure, the shell is nice when you're interacting with it, but calling the shell from your own program is crazy. Similarly, the fact that databases don't offer any structured query fomat and insist on plain text SQL (even with the kludge of prepared statements) is a horrible idea, that has bit everyone time and time again.
- mgaunard 5y agoIt's not hard at all. The target programming language has a well-defined grammar that says which special characters need to be escaped in strings, and a mechanism to do so, be that in the case of SQL, sh or printf formatters. Not doing it is just plain incompetence.
- tsimionescu 5y agoIt's only easy if you want to escape everything. If there is any intention to mix escaped and unescaped text, it becomes much more difficult.
- mgaunard 5y agoNo it isn't. You just need to formally specify what you want to happen, then reason as to whether this leads to adequate semantics for the component being built, and iterate until satisfactory semantics are achieved. This just happens to be the definition of programming.