News for hackers. Stuff that matters.
Re:Userdir URLs like https://example.org/~username/ are dang... by jl258 on Wednesday April 08, 2020 @09:02AM (#22812524)
Commenter above, correct me if I’m misinterpreting, but — I imagine they meant for when programs talk to other programs. Regexes and string literals are written by humans; it would be easy for the compiler/program to calculate the length for you.
Re:Userdir URLs like https://example.org/~username/ are dang... by jcranmer on Wednesday April 08, 2020 @09:39AM (#22812832)
The general solution is parametric construction. When we're building SQL queries, regular expression matchers, HTML files, etc., we're actually attempting to build a richer data structure but representing it as a flat string. Instead of concatenating strings, we can turn our original string into one where some leaf nodes are placeholders for future literal entities, which can be substituted for their actual values without fear of potential metacharacters that could be misinterpreted.

While the solution may be fairly clear, not everyone provides easy interfaces for parametric construction--regular expression engines being the one where the lack is the most distressing for me (although this is less because I need to substitute in user-generated strings and more because I want to combine smaller regexes into larger ones to make the regex easier to follow).

Re:Userdir URLs like https://example.org/~username/ are dang... by brazzy on Wednesday April 08, 2020 @09:15AM (#22812621)
Which would, again, only help with delimiters, but not with other characters that have special meaning but also need to be used literally.