Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Of course, this isn't a valid argument against format strings, because you could just as well write a function which does the same thing without language-level format strings

In that case, you should ask yourself what's the point of format strings at all? The answer is that they're more attractive because using them is more convenient. You want to make the more attractive feature the safer feature to draw people away from danger, not toward it.



It seems perverse to make a ubiquitous operation (formatting a string) intentionally hard just because some people may use it for inappropriate purposes such as building SQL queries from untrusted input. Sure, we should have ergonomic easy of building prepared statements and such but that doesn't seem like something that belongs in the standard library. Or maybe it does. But either way there are many, many legitimate use cases for string formatting.


But you don't need to make it harder in order to make it safer. You just need to think more about the security concerns and come up with solutions, as others have.


> You want to make the more attractive feature the safer feature to draw people away from danger, not toward it.

There's an entire world of software which does something else than creating SQL queries or HTML pages. Rust is a general purpose language, not some niche DSL. I use format strings all the time in my Rust code, yet I've never been in a situation where those strings should or could have been sanitized.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: