News for hackers. Stuff that matters.
Re:Java String Interpolation final in Java 23 by coldtea on Sunday January 14, 2024 @07:49PM (#38996079)
>But this feature is being added to Java to solve the pretty serious problem of code injection

My take is that it will do little for code injection. Most programmers will use STR/FMT, and unless they offer an HTML or an SQL processor in the stdlib, they wont be used.

>Remember, string templates are most useful when what they produce is not a string, but rather construct a specific API entity

Sure, but the processor can do little short of implementing full parsing to understand the context of say HTML or SQL, right?

Re:Java String Interpolation final in Java 23 by pron on Monday January 15, 2024 @06:36AM (#38999685)
> Most programmers will use STR/FMT, and unless they offer an HTML or an SQL processor in the stdlib, they wont be used.

New processors obviously can't be used unless they're offered by a library, but when they are, they must be used. The libraries simply won't offer an API based on strings (and, therefore, interpolated strings), or if they already do, they will be able to deprecate them. If an HTML library has no API that takes strings, then STR/FMT simply can't be used. The library can enforce the safety of its API.

> Sure, but the processor can do little short of implementing full parsing to understand the context of say HTML or SQL, right?

Yes, that's the point. An HTML library will offer an HTML processor, and similarly for a JSON or SQL library. I'm not apprised of the exact status, but I believe that the team specifying JDBC is looking into offering a SQL processor as part of JDBC.