News for hackers. Stuff that matters.
Re:That people produce HTML with string templates is telling... by 1lint on Friday May 26, 2023 @04:53PM (#36089381)
If we don't care about the UX, then it would be more "convenient" for the developer to just not write the program in the first place.

Using string templating makes the DX better without compromising UX, since users just see the rendered output. Implementing bad/nonexistent web security also makes the DX easier since there's simply fewer features to implement, but this obviously has negative consequences on UX when folks have their accounts/credentials easily stolen.

Re:That people produce HTML with string templates is telling... by yencabulator on Friday May 26, 2023 @05:09PM (#36089543)
Using string templating for HTML is bad/nonexistent web security, so by your argument it does compromise UX.
Re:That people produce HTML with string templates is telling... by 1lint on Friday May 26, 2023 @06:08PM (#36090089)
By your argument, everyone using string templating for HTML has bad/nonexistent web security. I disagree.
Re:That people produce HTML with string templates is telling... by yencabulator on Friday May 26, 2023 @06:14PM (#36090137)
Not everyone, just the people whose pages display untrusted inputs. Which is a huge fraction of the modern web...

(The rest just have brittle websites that might break when someone uses certain punctuation for the first time.)

Re:That people produce HTML with string templates is telling... by 1lint on Friday May 26, 2023 @07:04PM (#36090482)
Ah okay I see now you were referring to failure to sanitize inputs/outputs in the original comment. I don't know if this oversight occurs more often when using string templating, but I'm pretty sure this was already a problem long before string templating came into practice.
Re:That people produce HTML with string templates is telling... by yencabulator on Friday May 26, 2023 @09:14PM (#36091187)
It's literally the reason why HTML templating is done with other means than string concatenation, these days.
Re:That people produce HTML with string templates is telling... by hirvi74 on Friday May 26, 2023 @08:31PM (#36090993)
Isn't that why server side validation exists? What's wrong with letting the user enter whatever they want? It doesn't mean it has to be accepted.
Re:That people produce HTML with string templates is telling... by yencabulator on Friday May 26, 2023 @09:13PM (#36091180)
Validation can force usernames to be a-z but it doesn't work on freeform text. Forum comments should be able to state that the HTML open comment syntax is <!--
Re:That people produce HTML with string templates is telling... by tomjakubowski on Friday May 26, 2023 @08:20PM (#36090941)
Not really. Lots of template engines escape and/or sanitize interpolated expressions, according to the context, by default.
Re:That people produce HTML with string templates is telling... by yencabulator on Friday May 26, 2023 @08:23PM (#36090963)
Well that goes far beyond what I think of as "string templates", now you're parsing the string into HTML.